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: docs/rules/prefer-stateless-function.md
+44-7
Original file line number
Diff line number
Diff line change
@@ -8,32 +8,33 @@ This rule will check your class based React components for
8
8
9
9
* methods/properties other than `displayName`, `propTypes`, `render` and useless constructor (same detection as ESLint [no-useless-constructor rule](http://eslint.org/docs/rules/no-useless-constructor))
10
10
* instance property other than `this.props` and `this.context`
11
+
* extension of `React.PureComponent` ()
11
12
* presence of `ref` attribute in JSX
12
13
*`render` method that return anything but JSX: `undefined`, `null`, etc. (only in React <15.0.0, see [shared settings](https://github.com/yannickcr/eslint-plugin-react/blob/master/README.md#configuration) for React version configuration)
13
14
14
-
If none of these 4 elements are found, the rule will warn you to write this component as a pure function.
15
+
If none of these elements are found, the rule will warn you to write this component as a pure function.
15
16
16
-
The following pattern is considered warnings:
17
+
The following pattern is considered a warning:
17
18
18
-
```js
19
+
```jsx
19
20
var Hello =React.createClass({
20
21
render:function() {
21
22
return<div>Hello {this.props.name}</div>;
22
23
}
23
24
});
24
25
```
25
26
26
-
The following pattern is not considered warnings:
27
+
The following pattern is not considered a warning:
27
28
28
-
```js
29
+
```jsx
29
30
constFoo=function(props) {
30
31
return<div>{props.foo}</div>;
31
32
};
32
33
```
33
34
34
-
The following pattern is not considered warning in React <15.0.0:
35
+
The following pattern is not considered a warning in React <15.0.0:
35
36
36
-
```js
37
+
```jsx
37
38
classFooextendsReact.Component {
38
39
render() {
39
40
if (!this.props.foo) {
@@ -43,3 +44,39 @@ class Foo extends React.Component {
0 commit comments