Skip to content

Commit 5a2e453

Browse files
chiawendtljharb
authored andcommitted
[Docs] display-name: improve examples
1 parent 5d0e932 commit 5a2e453

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@ This change log adheres to standards from [Keep a CHANGELOG](https://keepachange
1818
* [Docs] HTTP => HTTPS ([#3133][] @Schweinepriester)
1919
* [readme] Some grammar fixes ([#3186][] @JJ)
2020
* [Docs] [`jsx-no-target-blank`]: Improve readme ([#3169][] @apepper)
21+
* [Docs] [`display-name`]: improve examples ([#3189][] @golopot)
2122

23+
[#3189]: https://github.com/yannickcr/eslint-plugin-react/pull/3189
2224
[#3186]: https://github.com/yannickcr/eslint-plugin-react/pull/3186
2325
[#3174]: https://github.com/yannickcr/eslint-plugin-react/pull/3174
2426
[#3169]: https://github.com/yannickcr/eslint-plugin-react/pull/3169

docs/rules/display-name.md

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,14 @@ var Hello = createReactClass({
1212
return <div>Hello {this.props.name}</div>;
1313
}
1414
});
15+
16+
const Hello = React.memo(({ a }) => {
17+
return <>{a}</>
18+
})
19+
20+
export default ({ a }) => {
21+
return <>{a}</>
22+
}
1523
```
1624

1725
Examples of **correct** code for this rule:
@@ -23,6 +31,10 @@ var Hello = createReactClass({
2331
return <div>Hello {this.props.name}</div>;
2432
}
2533
});
34+
35+
const Hello = React.memo(function Hello({ a }) {
36+
return <>{a}</>
37+
})
2638
```
2739

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

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

40-
Examples of **correct** code for this rule:
52+
Examples of **correct** code for `{ ignoreTranspilerName: true }` option:
4153

4254
```jsx
4355
var Hello = createReactClass({
@@ -66,7 +78,7 @@ export default function Hello({ name }) {
6678
Hello.displayName = 'Hello';
6779
```
6880

69-
Examples of **incorrect** code for this rule:
81+
Examples of **incorrect** code for `{ ignoreTranspilerName: true }` option:
7082

7183
```jsx
7284
var Hello = createReactClass({

0 commit comments

Comments
 (0)