New
Introducing React Doctor for Enterprise

react-hooks-js/void-use-memo

Validates that useMemos always return a value and that the result of the useMemo is used by the component/hook. See [`useMemo()` docs](https://react.dev/reference/react/useMemo) for more information.

Validation prompt

Use this to decide whether a fired diagnostic is real or a false positive.

Fires when a useMemo's return value is never consumed — not assigned, not destructured, not returned from the surrounding component/hook. The cached value is computed and immediately discarded, so the hook is effectively a side-effect call dressed up as memoization. False positive: rare; an unused memo is almost always a mistake.

Fix prompt

Use this once validation confirms the diagnostic is real.

Assign the result and reference it downstream (const sorted = useMemo(() => [...items].sort(), [items]); return <List items={sorted} />). If you do not need the value, you do not need the memo — delete it and either move the work to useEffect for synchronization or to an event handler for user-triggered side effects. See https://react.dev/reference/eslint-plugin-react-hooks

More React Compiler rules from the rules reference:

  • react-hooks-js/component-hook-factories: Deprecated: this rule has been removed in 7.1.0.
  • react-hooks-js/error-boundaries: Validates usage of error boundaries instead of try/catch for errors in child components
  • react-hooks-js/globals: Validates against assignment/mutation of globals during render, part of ensuring that [side effects must render outside of render](https://react.dev/reference/rules/components-and-hooks-must-be-pure#side-effects-must-run-outside-of-render)
  • react-hooks-js/hooks: Validates the rules of hooks
  • react-hooks-js/immutability: Validates against mutating props, state, and other values that [are immutable](https://react.dev/reference/rules/components-and-hooks-must-be-pure#props-and-state-are-immutable)