Good read! Question on number 2: Would we not want to keep the function as dependency and let the user solve it, either with useCallback or by letting the user move the isInteractive function outside if the component:
The answer depends on the use-case. Some things are not supposed to change in runtime and it is nice to move them out of the dependencies tracking logic altogether
Good read! Question on number 2: Would we not want to keep the function as dependency and let the user solve it, either with useCallback or by letting the user move the isInteractive function outside if the component:
With this, you can still closure over a prop in
isInteractive
if you want toThe answer depends on the use-case. Some things are not supposed to change in runtime and it is nice to move them out of the dependencies tracking logic altogether
For example, you can see this pattern in react-redux hook: react-redux.js.org/api/hooks#custo...