I
I
ivan05122020-01-22 23:05:28
React
ivan0512, 2020-01-22 23:05:28

Is it worth taking data from data parameters?

Tell me, as far as I understand, it is highly undesirable to pass event handlers to components that will be created anew each time, that is, onClick={() => action()}.
It is correct to move the handler to a variable and then it will not be created anew each time.
Then the question arises, how can you pass data to the parent component? onClick={() => props.handler(data)} can't be done anymore. Somewhere I saw an option to leave the data in the data attributes, and in the handler to take them from there.
To what extent is this practice necessary or are these already unnecessary troubles, and this problem is far-fetched?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
Y
y0u, 2020-01-22
@y0u

How to pass data from child component to parent in react?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question