When fetching data I\'m getting: Can\'t perform a React state update on an unmounted component. The app still works, but react is suggesting I might be causing a memory leak
For me, clean the state in the unmount of the component helped.
const [state, setState] = useState({}); useEffect(() => { myFunction(); return () => { setState({}); // This worked for me }; }, []); const myFunction = () => { setState({ name: 'Jhon', surname: 'Doe', }) }