I'm trying to gather the input data from a form dynamically rather than typing out each individual input field name. This was pretty easy using standard React, but I'm switching over to React Hooks and now I'm a bit confused on how to achieve the same goal.
const gatherFormData = e => {
if (e.target.value !== null) {
_.assign(
formData.payload,
{ [e.target.name]: e.target.value, action },
{ groupNumber },
);
setState({
[e.target.name]: (e.target.value),
formData
});
}
};
I tried using template literal syntax, but that didn't work.
set`${e.target.name}`(e.target.value);