undux
undux copied to clipboard
exhaustive-deps issue
My code:
const App = () => {
useSelectedObj({ a: 1 })
return <>...</>
}
export function useSelectedObject(obj) {
const store = Store.useStore()
useEffect(() => {
store.set('obj')([obj])
return () => store.set('obj')(null)
}, [obj]) // eslint error here
}
The eslint error I get:
React Hook useEffect has a missing dependency: 'store'. Either include it or remove the dependency array react-hooks/exhaustive-deps
Including store
in the dependency array makes it go into an infinite loop. What am I doing wrong here and what should I do instead? Should I silence the eslint error?
Didn't find anything in the documentation or existing issues regarding this.