In my project, I create a custom react hook that needs to use observable state in store for dependencies of useEffect:
My example custom hook:
const useFoo = (() => {
const { count } = store;
useEffect (() => {
//do something here
},[count])
})
Normally we must wrap observer() the component to make it rerender but observer() does not accept wrap custom hook. I have already referred to another question in this question but this isn't clearly answered to me.
So Anyone can give me a solution to do this. I realize custom hook should be isolated from data to be reusable but in my case, I will save a lot of time to refactor code if I have solution for this problem. Thanks a lot