Merge pull request #1620 from lasota-piotr/classname-props

[guide] [react] Added anti-pattern example for Props Naming rule, changed className props in examples
This commit is contained in:
Jordan Harband
2017-10-25 13:33:52 -07:00
committed by GitHub

View File

@@ -143,6 +143,9 @@
// bad
<MyComponent style="fancy" />
// bad
<MyComponent className="fancy" />
// good
<MyComponent variant="fancy" />
```
@@ -400,7 +403,7 @@
```jsx
// bad
render() {
return <MyComponent className="long body" foo="bar">
return <MyComponent variant="long body" foo="bar">
<MyChild />
</MyComponent>;
}
@@ -408,7 +411,7 @@
// good
render() {
return (
<MyComponent className="long body" foo="bar">
<MyComponent variant="long body" foo="bar">
<MyChild />
</MyComponent>
);
@@ -427,10 +430,10 @@
```jsx
// bad
<Foo className="stuff"></Foo>
<Foo variant="stuff"></Foo>
// good
<Foo className="stuff" />
<Foo variant="stuff" />
```
- If your component has multi-line properties, close its tag on a new line. eslint: [`react/jsx-closing-bracket-location`](https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-closing-bracket-location.md)