arrow_backBACK TO DRILLS
Blue BeltuseeffectPREMIUM
Async Function Passed Directly to useEffect Returns a Promise Not a Cleanup Function
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?