← React Intermediate Questions - Set 4 Q33

How do you handle asynchronous operations in React?

React Intermediate Questions - Set 4

Example

useEffect(() => {
  let alive = true;
  fetchData().then(d => { if (alive) setData(d); });
  return () => { alive = false; };
}, []);

What to notice

← Back to the question list