DEV Community

Discussion on: React — Access custom params in handlers the right way

Collapse
 
guico33 profile image
guico33

The example given isn't relevant. If the id is coming from the props object, one can simply read it from through the closure in which case passing the data as an id to the html element and reading it from the event is useless.

If performance is a concern, one can also create a new component, pass the the necessary data as a prop and define the callback in the child.
I guess the described method could be useful for optimisation when dealing with third-party components though.

Collapse
 
flexdinesh profile image
Dinesh Pandiyan

The example was to give an idea that values can be stored as data attributes. I'll update the example to access state values so it's obvious.