James Brightman
May 12, 2022

--

Hi, glad you enjoyed the article.

I’m not sure I can answer your question with 100% certainty. Intuitively I’d think that just having an empty deps array would only memoize the function once, similar to how useEffect with empty deps runs once.

useCallback with no deps definitely feels like an “anti-pattern” but I can’t explain exactly why. In practice, I would probably experiment to see which causes fewer rerenders of children, useEvent or useCallback with empty deps.

--

--

James Brightman
James Brightman

Written by James Brightman

I write about stuff I find interesting. Usually WebDev, React and occasionally Finance.

Responses (1)