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 committed Jan 27, 2022
1 parent 2dfe98f commit e7484b7
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions docs/rules/display-name.md
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 e7484b7

Please sign in to comment.