Source: www.amitmerchant.com

Curried event handlers in React.js
When working with https://reactjs.org/ components, you might end up in a situation where you would be using an event handler more than once. import React from 'react'; function MyComponent() { handleClick(e, count) { console.log(e, count)} render() { return( handleClick(e, }>Clicked once handleClick(e, }>Clicked twice handleClick(e, }>Clicked thrice As you can tell, we have a functional component called and inside this component, there are a few links whose onClick event is being bound by a handler handleClick. Notice, we pass in the https://developer.mozilla.org/en-US/docs/Learn/JavaScript/Building_blocks/Events e and count as the arguments to this handler.

So, we don’t need to explicitly pass in the event when calling the handler.
Newsletter

Get the latest Laravel/PHP jobs, events and curated articles straight to your inbox, once a week

Fathom Analytics | Fast, simple and privacy-focused website analytics. Fathom Analytics | Fast, simple and privacy-focused website analytics.
Achieve superior email deliverability with ToastMail! Our AI-driven tool warms up inboxes, monitors reputation, and ensures emails reach their intended destination. Sign up today for a spam-free future. Achieve superior email deliverability with ToastMail! Our AI-driven tool warms up inboxes, monitors reputation, and ensures emails reach their intended destination. Sign up today for a spam-free future.
Community Partners