My onChange handler for submitting a form with multiple input values and takes in whatever the name attribute of the given input field is. So i basically know what this code does, but i don't know exactly what happens under the hood.
Why the brackets in [e.target.name] ?
I also know that in this case setFormData({ ...formData, name: e.target.value}); the function would every time just change the value of the input field with the attribute name.
const Register = ({ setAlert, register, isAuthenticated }) => {
  const [formData, setFormData] = useState({
    name:"",
    email:"",
    password: "",
    password2: ""
  }); 
  const {name, email, password, password2} = formData;
  const onChange = e => 
    setFormData({ ...formData, [e.target.name]: e.target.value});
Would be nice if somebody would know it.
 
     
    