0

I've never used an arrow function like this the code do works but I want to know how

handleChange = (input) => (e) => {
 this.setState({ [input]: e.target.value });
};
Nischal
  • 39
  • 2
  • This is a _higher-order function_ that creates change handlers. For example, calling `handleChange("fistName")` would create a change handler for the `firstName` property. You might then see it used in a form like this: `` – Nick Nov 06 '21 at 19:07
  • I'd argue that if you you have a `name` prop on the component you can just call `handleChange` and use the `name` to set the new state. Having a function return a closure to update the state seems superfluous. – Andy Nov 06 '21 at 19:13

0 Answers0