react-hooks-js/use-memo
Validates usage of the useMemo() hook against common mistakes. See [`useMemo()` docs](https://react.dev/reference/react/useMemo) for more information.
- Category: React Compiler
- Severity: error
- Source:
eslint-plugin-react-hooks - Framework: global
- Enabled when: eslint-plugin-react-hooks v6+ installed AND React Compiler detected in project
- Documentation: https://react.dev/reference/eslint-plugin-react-hooks/lints/use-memo
Validation prompt
Use this to decide whether a fired diagnostic is real or a false positive.
Fires on a useMemo whose callback has no return statement (it falls through and the memo's value is undefined). The cached value is therefore always undefined, making the hook useless and almost certainly indicating the wrong hook was chosen. False positive: a deliberately-empty stub left during refactoring — but the right fix is still to remove or repurpose it.
Fix prompt
Use this once validation confirms the diagnostic is real.
Add an explicit return for the computed value: useMemo(() => data.map(transform), [data]). If the body is purely side effects (analytics, logging, DOM writes), switch to useEffect for synchronization-style work or move the call into the event handler that triggers it. useMemo is for caching expensive computations, not for running code on dep change. See https://react.dev/reference/eslint-plugin-react-hooks/lints/use-memo