-
Notifications
You must be signed in to change notification settings - Fork 47k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Prop to pass data to event handlers #12169
Comments
My point was to have a way to pass data through to the handler and avoid the need for any of the above work arounds. (I should have added HOC's there, which is what I've been doing on a case by case for this situation)
|
To me, this does not sound like something that It just seems like baking in a use-case when there are tools that solve it already. |
Please direct API change proposals to this repository: https://github.com/reactjs/rfcs Generally binding or passing a closure is the idiomatic way to do it. |
This is a feature request
My suggestion is to add a known prop that gets passed through to all handlers as the second parameter. This would eliminate the need for closures, inline binding, inline arrow functions, proxyEvent.target.dataset, etc.
Currently if we need to pass
data
through an event handler there are several ways...Create a class method that returns a closure:
use inline bind or arrow function
AND
A not so intuitive alternative is to use
proxyEvent.target.dataset
If you pass an object to any
data-
prop it gets converted to a string. My immutable Map becomesDOMStringMap {button: "Map { "id": "84280bcc-ab3b-45d5-8882-dc74a17da...
so I have to pass an ID and use it in the handler to find my data.The text was updated successfully, but these errors were encountered: