jsx-no-lambda and passing args in event handlers
See original GitHub issueIf one never uses lambdas in a jsx arg, how would one pass args to an event handler? For example:
<Foo onClick={ (event) => this.foo(23) }/>
Issue Analytics
- State:
- Created 6 years ago
- Reactions:33
- Comments:51 (9 by maintainers)
Top Results From Across the Web
Passing arguments to event handlers in react - Stack Overflow
It's defined somewhere in the React component you're looking at. Find the function definition to see what its arguments are and what it...
Read more >Day 10: Passing Arguments to Event Handler in React - Medium
Learn how to pass arguments via Arrow Function and Bind Method. Most of the time, we may need to pass arguments to our...
Read more >Passing Arguments to Event Listeners in JavaScript
Passing arguments to an event handler can be particularly useful when the handler is reused for different events. For example, we want to...
Read more >Passing Arguments to Event Handlers - TutorialsWebsite
Passing arguments to event handler Using Bind Function or Method. You don't need to pass “e” (React Event Object) as an argument. With...
Read more >How to pass a parameter to an event handler or callback
This will help you to understand the underlying logic of event handlers and passing parameters through it. Creating React Project:.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
You can do
onClick={this.foo.bind(this, 23)}
but I would question why this is necessary.23
should be either a prop or part of state.In ES6 you should be able to use currying, eg: