G
G
GeorgeKay2021-11-30 08:30:42
JavaScript
GeorgeKay, 2021-11-30 08:30:42

What does this handleChange = (name) => ({ target }) => {} syntax mean?

handleChange = (name) => ({ target }) => {
    this.setState({ [name]: target.value });
  };

it’s not clear at all with these two arrows,
I understand this is such an abbreviation, but if you write expanded how the same code will look

Answer the question

In order to leave comments, you need to log in

2 answer(s)
L
Lynn "Coffee Man", 2021-11-30
@GeorgeKay

https://learn.javascript.ru/arrow-functions-basics
Function returns a function

K
kirillcka_markoff, 2021-11-30
@kirillcka_markoff

handleChange returns a function with a state change.
it is most likely used something like this:
<input onChange={() => handleChange('name')} />
in handleChange you pass the name of the property in state in the second input target function

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question