Answers for "can't perform a react state update on an unmounted component. ant design"

1

Can't perform a React state update on an unmounted component

useEffect(() => {
  let isMounted = true;               // note mutable flag
  someAsyncOperation().then(data => {
    if (isMounted) setState(data);    // add conditional check
  })
  return () => { isMounted = false }; // cleanup toggles value, if unmounted
}, []);                               // adjust dependencies to your needs
Posted by: Guest on August-27-2021

Code answers related to "can't perform a react state update on an unmounted component. ant design"

Code answers related to "Javascript"

Browse Popular Code Answers by Language