Skip to content

Comment on Lead says async func in useCallback is incorrect, use useMemo instead, WTF?

Comments

You can memoize any function with `useCallback`, sync or async. All it's doing is watching when the deps array changes, and saving whatever function reference was passed in at that time.

(Note that this does not mean that the function itself is memoized in terms of "cache the result and check the arguments to see if we know this answer already".)

Thanks! Yeah those were my thoughts too.

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.