useeffect only update state append to state code example
Example: how to setstate in useeffect
React.useEffect(() => {
let didCancel = false;
// ...
// you can check didCancel
// before running any setState
// ...
return () => {
didCancel = true;
};
});