3
edits
(Moved the getting rid of ESLint errors section up) |
(Added content for React / Redux section) |
||
Line 149: | Line 149: | ||
== React & Redux == | == React & Redux == | ||
=== Basic code style === | |||
You can find React-specific code style rules in the .eslintrc file. | |||
=== Components === | |||
* Default to creating components as [https://facebook.github.io/react/docs/reusable-components.html#stateless-functions stateless function components]. | |||
* If you need local state, lifecycle methods, or to access the DOM node, you’ll need to use a class-based component instead. Make sure there is a comment explaining why you needed it. | |||
=== PropTypes === | |||
* Use PropTypes to define the expected properties of your component. Each directly accessed property (or child of a property) should have a corresponding PropType. | |||
* Use isRequired for any required properties. | |||
* Place the propTypes definition at the top of the component. If using a stateless function component, place it above the declaration of the function. | |||
* Where the children property is used, consider [http://www.mattzabriskie.com/blog/react-validating-children validating the children]. |
edits