1

While reading through the docs of MUI , I encountered with a new syntax of the arrow function in js and I didn't see it anywhere. I tried to understand it's working and I can't find it anywhere.

The syntax is followed by

  const handleChange = (prop) => (event) => {
    setValues({ ...values, [prop]: event.target.value });
  };

and it passes to the onChange event like this

      <EmailText
        label="Email"
        type={"email"}
        onChange={handleChange("email")}
      />

How does this function work and what is the meaning of this function and how did the onChange pass the event parameter to the function?

aravind ks
  • 612
  • 7
  • 18

1 Answers1

0

handleChange function returns new function. which means when you call it - you will get a function expression and NOT a function call, this is way you can call it in the onClick without wrapping it in another arrow function

Yosi Leibman
  • 386
  • 3
  • 16