# Warning: useEffect must not return anything besides a function, which is used for clean-up. You returned: undefined

- **ID:** `react/useeffect-cleanup-return-non-function`
- **Domain:** react
- **Category:** runtime_error
- **Verification:** ai_generated
- **Fix Rate:** 90%

## Root Cause

The useEffect callback returns a non-function value (e.g., undefined from an async function, a Promise, or a number) instead of a cleanup function or nothing.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| react@18.2.0 | active | — | — |
| react@16.14.0 | active | — | — |

## Workarounds

1. **Define an async function inside the useEffect and call it without returning it. The useEffect callback itself should not be async.** (95% success)
   ```
   Define an async function inside the useEffect and call it without returning it. The useEffect callback itself should not be async.
   ```
2. **If a cleanup is needed, return a function that performs the cleanup. If not, omit the return statement entirely.** (90% success)
   ```
   If a cleanup is needed, return a function that performs the cleanup. If not, omit the return statement entirely.
   ```

## Dead Ends

- **Making the useEffect callback async directly (async () => { ... })** — An async function always returns a Promise, which is not a cleanup function, triggering the warning. (95% fail)
- **Adding a return statement that returns a string or boolean to suppress the warning** — Only a function (or nothing) is allowed; any other type will still cause the warning. (90% fail)
- **Wrapping the entire useEffect in a try-catch block** — The warning is about the return type of the callback, not about errors inside it; try-catch doesn't change the return value. (75% fail)
