1. Syntax, write code based on the order in which the life cycle method executes
(1 life cycle method [,,,,,,,,, getDefaultProps
getInitialState
componentWillMount
componentDidMount
componentWillReceiveProps
shouldComponentUpdate
componentWillUpdate
componentDidUpdate
componentWillUnmount]
Detailed life cycle details see: http://www.cnblogs.com/daomul/p/4856101.html
(2 other private methods
(3 render () method
2, the event handler function named: "Handle+eventname"
<onClickonlaunchmissiles/>
3. Component Verification
React components should be propTypes
validated. Each this.props
attribute should have one corresponding to it propTypes
.
Avoid using these prop-types that do not have a descriptive meaning:
- React.PropTypes.any
- React.PropTypes.array
- React.PropTypes.object
Best to use:
- React.PropTypes.arrayOf
- React.PropTypes.objectOf
- React.PropTypes.instanceOf
- React.PropTypes.shape
4, can props
not use state
, this can reduce the complexity of the application to a certain extent
5, minimize the use of jquery to operate the DOM (if necessary, the jquery plug-in package in the React component)
6, try not to use for example backbone model, can be used directly flux action
, or $.ajax
to replace.
React According to the official summary of the norms