0

I am trying to fetch data from json file in firebase. I get this error before the app loads sometimes. The App still works.

Warning: Can't perform a React state update on an unmounted component. This is a no-op, but it indicates a memory leak in your application. To fix, cancel all subscriptions and asynchronous tasks in a useEffect cleanup function.

Kindly help me to fix this.

Here is my code :

const [dataSource, setData] = useState([]);
  useEffect(() => {
    fetch("https://jsonurlcomeshere/banners.json")
      .then((response) => response.json())
      .then((responseJson) => {
        setData(responseJson);
      })
      .catch((error) => {
        console.error(error);
      });
  }, []);
Sva
  • 135
  • 1
  • 12
  • Similar question: https://stackoverflow.com/q/54954385/5669120 – Ketan Ramteke Dec 05 '20 at 22:40
  • Does this answer your question? [React-hooks. Can't perform a React state update on an unmounted component](https://stackoverflow.com/questions/56442582/react-hooks-cant-perform-a-react-state-update-on-an-unmounted-component) – nipuna-g Dec 06 '20 at 12:04

0 Answers0