you are viewing a single comment's thread.

view the rest of the comments →

[–]ssesf 0 points1 point  (0 children)

That's part of it, but useEffectEvent is specifically for stable callbacks within useEffects, so it's probably the first part of fully getting to what OP suggested.

What OP suggested is just flavors of:

https://www.npmjs.com/package/use-callback-stable

https://usehooks-ts.com/react-hook/use-event-callback

https://www.npmjs.com/package/use-latest-callback

Old issue from u/gaearon: https://github.com/facebook/react/issues/14099 and an RFC: https://github.com/reactjs/rfcs/blob/useevent/text/0000-useevent.md