React three core components properties (props, state, refs)

1, propsproperty

react said unidirectional data flow value is said props, according to this characteristic it also has a role: communications between components. props itself is immutable, but there is a situation that looks like a variable, that is the parent component of the state as props subassembly, when state change parent component, sub-assembly of props also followed the change, in fact, it still follows this a law of: props can not be changed.

propsProperty features:

1. Each component object will have props (properties shorthand) properties

2. The component tag all the attributes are stored in the props

3. Internal read a property value: this.props.propertyName

4. Role: outward transfer of data from the module assembly by tag attributes (read only read only)

The property value of the props and the need to limit the type of restriction

The sample code

Use the function components:

import React from 'react';
import ReactDOM from 'react-dom';

//使用函数组件
function 

Guess you like

Origin blog.csdn.net/p445098355/article/details/105217632