React Hooks - useEffect and useCallback
Today, I am continuing my Todo App and I encountered a React Warning:
React Hook useEffect has a missing dependency: 'tasksContext'.
Either include it or remove the dependency array react-hooks/exhaustive-deps
Either include it or remove the dependency array react-hooks/exhaustive-deps
when adding a function in my useEffect hook to simulate componentDidMount.
I solved it by using a useCallback hook to avoid causing an infinite loop due to infinitely recreating the function in the useEffect hook.
Found the article below useful:
Comments
Post a Comment