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

- **ID:** `react/useEffect-return-not-function`
- **Domain:** react
- **Category:** runtime_error
- **Verification:** ai_generated
- **Fix Rate:** 92%

## Root Cause

The useEffect callback returns a value that is not a function or undefined, violating React's contract for effect cleanup.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| React 16.8+ | active | — | — |
| React 17.x | active | — | — |
| React 18.x | active | — | — |

## Workarounds

1. **Ensure useEffect callback returns either nothing (undefined) or a cleanup function. Example: useEffect(() => { const timer = setInterval(...); return () => clearInterval(timer); }, []);** (95% success)
   ```
   Ensure useEffect callback returns either nothing (undefined) or a cleanup function. Example: useEffect(() => { const timer = setInterval(...); return () => clearInterval(timer); }, []);
   ```
2. **If you need async logic, define the async function inside the effect and call it, but do not return the promise. Example: useEffect(() => { const fetchData = async () => { ... }; fetchData(); }, []);** (90% success)
   ```
   If you need async logic, define the async function inside the effect and call it, but do not return the promise. Example: useEffect(() => { const fetchData = async () => { ... }; fetchData(); }, []);
   ```

## Dead Ends

- **Returning null or false from useEffect to suppress the warning.** — React expects either undefined (no cleanup) or a function; returning null/false triggers the same error because they are not functions. (90% fail)
- **Removing the return statement entirely even when cleanup is needed.** — Without a cleanup function, subscriptions, timers, or event listeners may persist, causing memory leaks or duplicate effects. (70% fail)
- **Wrapping the return value in an async function (e.g., useEffect(async () => { ... return someValue; })).** — Async functions always return a Promise, which is not a function for cleanup; React will throw the same error. (95% fail)
