Skip to content

Commit

Permalink
[Docs] display-name: improve examples
Browse files Browse the repository at this point in the history
  • Loading branch information
golopot authored and ljharb committed Jan 27, 2022
1 parent 5d0e932 commit 5a2e453
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ This change log adheres to standards from [Keep a CHANGELOG](https://keepachange
* [Docs] HTTP => HTTPS ([#3133][] @Schweinepriester)
* [readme] Some grammar fixes ([#3186][] @JJ)
* [Docs] [`jsx-no-target-blank`]: Improve readme ([#3169][] @apepper)
* [Docs] [`display-name`]: improve examples ([#3189][] @golopot)

[#3189]: https://github.com/yannickcr/eslint-plugin-react/pull/3189
[#3186]: https://github.com/yannickcr/eslint-plugin-react/pull/3186
[#3174]: https://github.com/yannickcr/eslint-plugin-react/pull/3174
[#3169]: https://github.com/yannickcr/eslint-plugin-react/pull/3169
Expand Down
16 changes: 14 additions & 2 deletions docs/rules/display-name.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,14 @@ var Hello = createReactClass({
return <div>Hello {this.props.name}</div>;
}
});

const Hello = React.memo(({ a }) => {
return <>{a}</>
})

export default ({ a }) => {
return <>{a}</>
}
```

Examples of **correct** code for this rule:
Expand All @@ -23,6 +31,10 @@ var Hello = createReactClass({
return <div>Hello {this.props.name}</div>;
}
});

const Hello = React.memo(function Hello({ a }) {
return <>{a}</>
})
```

## Rule Options
Expand All @@ -37,7 +49,7 @@ var Hello = createReactClass({

When `true` the rule will ignore the name set by the transpiler and require a `displayName` property in this case.

Examples of **correct** code for this rule:
Examples of **correct** code for `{ ignoreTranspilerName: true }` option:

```jsx
var Hello = createReactClass({
Expand Down Expand Up @@ -66,7 +78,7 @@ export default function Hello({ name }) {
Hello.displayName = 'Hello';
```

Examples of **incorrect** code for this rule:
Examples of **incorrect** code for `{ ignoreTranspilerName: true }` option:

```jsx
var Hello = createReactClass({
Expand Down

0 comments on commit 5a2e453

Please sign in to comment.