DEV Community

loading...

Discussion on: Fast & easy... React states management in one function

patroza profile image
Patrick Roza

No worries, just wanted to chip in. Somehow dont see a note about rerender, I'm on mobile, perhaps some caching going on.

I like the alternative via name prop for input elements, or a custom data prop, as I wrote in the other comment thread.

Alternatively, I would still create a function property per onChange handler, but create and use a reusable function to limit the repetitiveness to the bare minimum.

Thread Thread
acostalima profile image
André Costa Lima

You can create a curried function and then memoize it. 😉 It should work! Have a look at Lodash's curry and memoize functions.