# Warning: React.memo: The comparison function returned true for props that are not equal. This may cause the component to skip rendering when it should update.

- **ID:** `react/memo-wrong-comparison`
- **Domain:** react
- **Category:** runtime_error
- **Verification:** ai_generated
- **Fix Rate:** 90%

## Root Cause

A custom comparison function passed to React.memo incorrectly returns true (equal) for props that are actually different, causing the component to skip re-renders when it should update.

## Version Compatibility

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

## Workarounds

1. **Fix the comparison function to correctly compare all relevant props. Example: const MyComponent = React.memo(Comp, (prevProps, nextProps) => { return prevProps.id === nextProps.id && prevProps.name === nextProps.name; }); Ensure it returns false when props differ.** (92% success)
   ```
   Fix the comparison function to correctly compare all relevant props. Example: const MyComponent = React.memo(Comp, (prevProps, nextProps) => { return prevProps.id === nextProps.id && prevProps.name === nextProps.name; }); Ensure it returns false when props differ.
   ```
2. **If the component relies on deep equality, use a library like lodash.isEqual for the comparison: import isEqual from 'lodash.isequal'; React.memo(Comp, isEqual);** (88% success)
   ```
   If the component relies on deep equality, use a library like lodash.isEqual for the comparison: import isEqual from 'lodash.isequal'; React.memo(Comp, isEqual);
   ```
3. **Remove the custom comparison function and let React.memo use default shallow comparison, but ensure props are immutable references.** (80% success)
   ```
   Remove the custom comparison function and let React.memo use default shallow comparison, but ensure props are immutable references.
   ```

## Dead Ends

- **** — Shallow comparison may still miss deep changes, and the warning indicates the custom function is buggy, not that shallow is better. (70% fail)
- **** — JSON.stringify is slow and can produce false positives for object key order; also triggers the same warning if not careful. (85% fail)
- **** — Defeats the purpose of memoization and may cause performance issues, but does not fix the underlying logic error. (65% fail)
