Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@ This change log adheres to standards from [Keep a CHANGELOG](https://keepachange
### Fixed
* [`display-name`]: fix false positive for HOF returning only nulls ([#3291][] @golopot)
* [`jsx-no-leaked-render`]: avoid unnecessary negation operators and ternary branches deletion ([#3299][] @Belco90)
* [`display-name`]: fix false positive when using memo ([#3304][] @golopot)

### Changed
* [Docs] [`jsx-tag-spacing`]: rename option from [#3264][] ([#3294[] @ljharb)
* [Docs] [`jsx-key`]: split the examples ([#3293][] @ioggstream)

[#3304]: https://github.com/jsx-eslint/eslint-plugin-react/pull/3304
[#3299]: https://github.com/jsx-eslint/eslint-plugin-react/pull/3299
[#3294]: https://github.com/jsx-eslint/eslint-plugin-react/issues/3294
[#3293]: https://github.com/jsx-eslint/eslint-plugin-react/pull/3293
Expand Down
2 changes: 1 addition & 1 deletion lib/util/Components.js
Original file line number Diff line number Diff line change
Expand Up @@ -515,7 +515,7 @@ function componentRule(rule, context) {

// Case like `React.memo(() => <></>)` or `React.forwardRef(...)`
const pragmaComponentWrapper = utils.getPragmaComponentWrapper(node);
if (pragmaComponentWrapper) {
if (pragmaComponentWrapper && utils.isReturningJSXOrNull(node)) {
return pragmaComponentWrapper;
}

Expand Down
13 changes: 13 additions & 0 deletions tests/lib/rules/display-name.js
Original file line number Diff line number Diff line change
Expand Up @@ -588,6 +588,19 @@ ruleTester.run('display-name', rule, {
}
`,
},
{
// issue #3303
code: `
function MyComponent(props) {
return <b>{props.name}</b>;
}

const MemoizedMyComponent = React.memo(
MyComponent,
(prevProps, nextProps) => prevProps.name === nextProps.name
)
`,
},
]),

invalid: parsers.all([
Expand Down