listener churn

Removing and re-adding the same event listener on every render because the handler function is new each time.

In more detail

It wastes work and can miss events in between. Storing the latest handler in a ref and subscribing once, re-subscribing only when the event type or target changes, avoids both churn and stale closures.

Related terms

Taught in

References