React According to the official summary of the norms

Source: Internet
Author: User

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 componentDidUpdatecomponentWillUnmount]

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.