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

Glimpse streamlines Laravel development by seamlessly deploying GitHub pull requests to preview environments with the help of Laravel Forge. Glimpse streamlines Laravel development by seamlessly deploying GitHub pull requests to preview environments with the help of Laravel Forge.
Fathom Analytics | Fast, simple and privacy-focused website analytics. Fathom Analytics | Fast, simple and privacy-focused website analytics.
Shirts painstakingly handcrafted by under-caffeinated developers. Shirts painstakingly handcrafted by under-caffeinated developers.
Community Partners