Skip to content

Commit

Permalink
Fix prefer-stateless-function (fixes #588)
Browse files Browse the repository at this point in the history
  • Loading branch information
yannickcr committed May 9, 2016
1 parent 59dcd65 commit 4e82b10
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions docs/rules/prefer-stateless-function.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ This rule will check your class based React components for

* 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))
* instance property other than `this.props` and `this.context`
* `render` method that return anything but JSX (`undefined`, `null`, etc.)
* presence of `ref` attribute in JSX
* `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)

If none of these 4 elements are found, the rule will warn you to write this component as a pure function.

Expand All @@ -23,14 +23,16 @@ var Hello = React.createClass({
});
```

The following patterns are not considered warnings:
The following pattern is not considered warnings:

```js
const Foo = function(props) {
return <div>{props.foo}</div>;
};
```

The following pattern is not considered warning in React <15.0.0:

```js
class Foo extends React.Component {
render() {
Expand Down

0 comments on commit 4e82b10

Please sign in to comment.