You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi! I’m looking at the source for userHover and I have a question about performance (and also hoping this will help me better understand React performance in general). Why not employ useCallback?
Digging deeper—is this just because useEventListener already works around this problem by tracking the handler inside a ref, which avoids removing and re-registering a handler in the DOM on every render? So… it’s negligible if the handler keeps changing it’s reference value?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hi! I’m looking at the source for userHover and I have a question about performance (and also hoping this will help me better understand React performance in general). Why not employ
useCallback
?Digging deeper—is this just because useEventListener already works around this problem by tracking the handler inside a ref, which avoids removing and re-registering a
handler
in the DOM on every render? So… it’s negligible if the handler keeps changing it’s reference value?I was assuming to see something like this:
or like this with a single useMemo:
but is the extra memory overhead actually a waste (especially given how useEventListener handles things)?
Beta Was this translation helpful? Give feedback.
All reactions