arrow_backBACK TO DRILLS
Blue BeltuseeffectPREMIUM
Passing an async Function Directly to useEffect
A developer wants an effect to fetch data and clean up an in-flight request on unmount.
REACT_MODULE // 0x42
useEffect(async () => {
const controller = new AbortController();
const data = await fetchData({ signal: controller.signal });
setData(data);
return () => controller.abort();
}, []);Why does the cleanup function returned from this effect never actually run?