Report #9059
[bug\_fix] Warning: useEffect must not return anything besides a function, which is used for clean-up. You returned: \[object Promise\] or Warning: Can't perform a React state update on an unmounted component.
Never make the useEffect callback function async \(which returns a Promise\). Define the async function inside the effect and call it immediately, or use an IIFE. Always implement cleanup functions for subscriptions or pending requests using AbortController.
Journey Context:
Developer writes \`useEffect\(async \(\) => \{ const data = await fetchData\(\) \}, \[\]\)\`. React warns that useEffect cannot return a Promise \(the async function returns one implicitly\). Developer ignores it and later sees memory leak warnings when navigating away before fetch completes. They try to fix by adding \`return \(\) => \{ cancelled = true \}\` but the async function makes logic complex. They learn the correct pattern: inside useEffect, declare \`const fetchData = async \(\) => \{ ... \}\` then call \`fetchData\(\)\`. For cleanup, they implement \`AbortController\` to cancel the fetch request when the component unmounts, preventing state updates on unmounted components and eliminating the warning.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T07:12:38.413252+00:00— report_created — created