When you have a hook that returns a function should you wrap the function in useCallback to make sure a new reference is not created unnecessarily?
My thought process is if that function was used by another hook in a dependency array, the new function reference would cause the 2nd hook to trigger even when nothing changes. Should a hook only change it's output when it had a reason to change, or is it alright if a hook is noisy?
function useExample(someParam) {
// ...
const onChange = () => { /*some operation*/ }
return { onChange }
}
function Component(props) {
const { onChange } = useExample(props)
useEffect(() =>
//Some action
, [onChange])
// ...
}