1 min read

The React team has published an RFC proposing a new React hook, currently called useEvent. The RFC received a lot of hype, and for good reason.

The React team has published an RFC proposing a new React hook, currently called useEvent. The RFC received a lot of hype, and for good reason.
Photo by Terry Vlisidis / Unsplash

The proposed hook solves a problem encountered by anyone who has ventured to optimize a React application. The RFC is summarized by the following statement:

"A hook for defining an event handler with an always-stable function identity."

What the React team means when it says that function identity is reference equality.  When a component is re-rendered, every function declared in it is re-created. If you have a memoized child component that refers to that function via props, it will see a change that causes it to be re-rendered.