Consider this contrived code snippet.
const foo = () => {return 1;}
const bar = useMemo(() => {return foo();}, [foo])
When I trigger a react-hooks/exhaustive-deps warning, I'll get a message like this.
The 'foo' function makes the dependencies of useMemo Hook (at line 2) change on every render. Move it inside the useMemo callback. Alternatively, wrap the definition of 'foo' in its own useCallback() Hook.
The warning gives me 2 recommendations: 1) bring foo inside of bar's useMemo callback, or 2) wrap the function inside a useCallback.
I could certainly do either. I'm just wondering: Is either of those options preferable over the other, and if so then why? And if your answer is "it depends", what exactly does it depend on?