# `react-hooks-js/preserve-manual-memoization`

Validate that React Compiler can preserve or exceed the observable guarantees of existing manual memoization

- **Status:** Active
- **Category:** React Compiler
- **Assessment:** Evidence-required risk
- **Required evidence:** source code
- **Default severity:** error
- **Scope:** All supported frameworks
- **Active when:** eslint-plugin-react-hooks v6+ installed AND React Compiler detected in project
- **Priority:** 54 (P2)
- **Source:** eslint-plugin-react-hooks
- **Rule set:** oxlint-plugin-react-doctor 0.9.3 (prompt schema 2)
- **Documentation:** [Official documentation](https://react.dev/reference/eslint-plugin-react-hooks/lints/preserve-manual-memoization)

## Validation prompt

Confirm the detector match and collect the required evidence before deciding whether an edit is warranted.

Confirm the exact compiler diagnostic and the intent of the existing useMemo, useCallback, or React.memo boundary. The lint reports when compilation would infer dependencies or memoization behavior that does not preserve the manual memo's guarantees. A dependency can be omitted only when React documents the captured value as stable, such as a state setter or reducer dispatch; do not assume an arbitrary callback or object is stable.

## Evidence boundary

The diagnostic proves only that the detector's modeled source pattern matched. It does not prove runtime impact, product intent, rendered failure, or that one remediation is correct.

Establish the environment, explicit repository policy, relevant exceptions, and required rendered or runtime evidence before deciding the occurrence. This page’s Assessment and Required evidence fields define the review contract.

Default severity is registry metadata. Use the occurrence's JSON severity after repository configuration when ordering real findings.

Record one outcome:

- **Confirmed failure:** The required evidence establishes the violation.
- **Rejected:** A documented exception or false-positive predicate applies.
- **Needs evidence:** Named evidence can still be collected.
- **Unavailable:** Required evidence cannot be collected in this run.
- **Waived with evidence:** An authorized, scoped exception applies to an established failure.
- **Observation:** The review records an optional tradeoff without claiming a defect.

A waiver records its scope, authority, evidence, and review or expiry condition. It is not a pass or false positive.

## Fix prompt

Apply this candidate correction only after the required evidence confirms the risk.

Preserve the existing memoization contract while making its dependencies complete and compiler-compatible. Add the genuinely reactive dependency or refactor the calculation so the same identity and recomputation boundaries remain explicit. Do not delete useMemo, useCallback, or React.memo solely to silence this lint: removal can change observable identity or downstream effect behavior even when compilation succeeds. Verify identity-sensitive consumers and focused tests. See https://react.dev/reference/eslint-plugin-react-hooks/lints/preserve-manual-memoization

## Repository-wide copy prompt

Use this only for a repository-wide pass after validating each occurrence. For one occurrence, use the occurrence-level guidance above.

````text
Fix every confirmed `react-hooks-js/preserve-manual-memoization` diagnostic in the current repository.

Required change:
- Preserve the existing memoization contract while making its dependencies complete and compiler-compatible. Add the genuinely reactive dependency or refactor the calculation so the same identity and recomputation boundaries remain explicit. Do not delete useMemo, useCallback, or React.memo solely to silence this lint: removal can change observable identity or downstream effect behavior even when compilation succeeds. Verify identity-sensitive consumers and focused tests. See https://react.dev/reference/eslint-plugin-react-hooks/lints/preserve-manual-memoization

Validation before editing:
Confirm the exact compiler diagnostic and the intent of the existing useMemo, useCallback, or React.memo boundary. The lint reports when compilation would infer dependencies or memoization behavior that does not preserve the manual memo's guarantees. A dependency can be omitted only when React documents the captured value as stable, such as a state setter or reducer dispatch; do not assume an arbitrary callback or object is stable.

Constraints:
- Confirm every occurrence independently.
- Make the smallest change that addresses the root cause.
- Preserve unrelated behavior, interfaces, content, and semantics.
- Reuse existing project conventions and components.
- Do not suppress the rule merely to clear the report.

Assessment:
- Record detector evidence, applicability, missing evidence, and one outcome: Confirmed failure, Rejected, Needs evidence, Unavailable, Waived with evidence, or Observation.

Verification:
- Run focused tests and every repository-mandated check.
- Run React Doctor and confirm the diagnostic no longer appears from changed code.
- Run an unfiltered scan of the affected scope before claiming no cross-category regression.
- Report checks that were not run instead of claiming they passed.
````
