You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -135,6 +135,7 @@ Enable the rules that you would like to use.
135
135
|||[react/no-access-state-in-setstate](docs/rules/no-access-state-in-setstate.md)| Reports when this.state is accessed within setState |
136
136
|||[react/no-adjacent-inline-elements](docs/rules/no-adjacent-inline-elements.md)| Prevent adjacent inline elements not separated by whitespace. |
137
137
|||[react/no-array-index-key](docs/rules/no-array-index-key.md)| Prevent usage of Array index in keys |
138
+
|| 🔧 |[react/no-arrow-function-lifecycle](docs/rules/no-arrow-function-lifecycle.md)| Lifecycle methods should be methods on the prototype, not class fields |
138
139
| ✔ ||[react/no-children-prop](docs/rules/no-children-prop.md)| Prevent passing of children as props. |
139
140
|||[react/no-danger](docs/rules/no-danger.md)| Prevent usage of dangerous JSX props |
140
141
| ✔ ||[react/no-danger-with-children](docs/rules/no-danger-with-children.md)| Report when a DOM element is using both children and dangerouslySetInnerHTML |
# Lifecycle methods should be methods on the prototype, not class fields (react/no-arrow-function-lifecycle)
2
+
3
+
It is not neccessary to use arrow function for lifecycle methods. This makes things harder to test, conceptually less performant (although in practice, performance will not be affected, since most engines will optimize efficiently), and can break hot reloading patterns.
4
+
5
+
## Rule Details
6
+
7
+
The following patterns are considered warnings:
8
+
9
+
```jsx
10
+
classHelloextendsReact.Component {
11
+
render= () => {
12
+
return<div />;
13
+
}
14
+
}
15
+
16
+
var AnotherHello =createReactClass({
17
+
render: () => {
18
+
return<div />;
19
+
},
20
+
});
21
+
```
22
+
23
+
The following patterns are **not** considered warnings:
24
+
25
+
```jsx
26
+
classHelloextendsReact.Component {
27
+
render() {
28
+
return<div />;
29
+
}
30
+
}
31
+
32
+
var AnotherHello =createReactClass({
33
+
render() {
34
+
return<div />;
35
+
},
36
+
});
37
+
38
+
```
39
+
## When Not To Use It
40
+
41
+
If you don't care about performance of your application or conceptual correctness of class property placement, you can disable this rule.
0 commit comments