React basic knowledge

Source: Internet
Author: User

Learning documents (by Priority)
Http://reactjs.cn/react/docs/tutorial-zh-CN.html
http://www.cnblogs.com/Mrs-cc/p/4969755.html (compatibility of ES5 with ES6)

React.createclass ()

We pass some methods in a JavaScript object to React.createclass () to create a new React component. The most important of these methods is render, which returns a React component tree, not the actual HTML, which will eventually be rendered as HTML.

Reactdom.render ()

Reactdom.render () Instantiates the root component, launches the framework, injects markup into the original DOM element, and provides as a second argument.
The Reactdom module exposes DOM-related methods, while React retains the core tools (such as React Native) that are shared by React on different platforms.

This.props

In JSX, you can place a text or React component in a tree by placing the JavaScript expression in curly braces (as a property or a child node). We use the This.props keys to access the named properties passed to the component to This.props.children access to any nested elements.
Props are immutable: they are transmitted from the parent and are "owned" by the parent.

This.props.data.map ()
var names = [‘Alice‘, ‘Emily‘, ‘Kate‘];names.map(function (name) {    return <div>Hello, {name}!</div>})
This.state

In order to achieve interaction, we introduced a mutable state to the component. State is reserved only for interactivity, that is, data that changes over time. This.state is a component-private and can be changed by calling This.setstate (). The component re-renders itself whenever the state is updated.

Getinitialstate ()

Getinitialstate () executes only once in the life cycle and sets the initial state of the component.

//es5getInitialState: function(){    return {liked: false};}
//es6constructor(props){    super(props);    this.state = {liked: false};}
This.setstate ()

Sets the value of the state within the component. The key to dynamic update is the call to This.setstate ().

Componentdidmount ()

Componentdidmount () is a method that is automatically called by react when a component is rendered.

React basic knowledge

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.