Home > Article > Web Front-end > What are the React properties? Detailed explanation on the use of react attributes, events and sharing
This article mainly talks about the use of attributes in react, as well as the use of react events and sharing. Next, let us read this article
The main content of this article Explain the use of attributes in React, React-specific tag acquisition, and the use of React sharing, etc., as follows:
State attribute of React
React's Props attribute
React event binding and two-way interaction of data
Reuse and verification of React components
React component Refs
Shared operation Mixins between React independent components
React's state machine is used to change the data of its own module;
The state scope only belongs to the current class and will not pollute other modules;
Initialization: this.state = {username: “XXX”};
The initialized state settings are placed in the constructor;
Modify state: this.setState({username: “AAA”});
promise.then( null, function( reason ){ /* rejection */} );// 等价于promise.catch( function( reason ){ /* rejection */} );
fetch("http://newsapi.gugujiankong.com/Handler.ashx?action=getnews&type=" + this.props.type + "&count=" + this.props.count, myFetchOptions).then(response => response.json()).then(json => this.setState({news: json}));
<BodyChild {...this.props} sex={"XXX}/>
;
Assign the shared object collection MixinLog to the current component prototype: ReactMixin(BodyIndex.prototype, MixinLog);
Make function calls corresponding to different needs That’s it, such as: MixinLog.log().
Features: has a similar life cycle to the page, and is executed several times after being called .
This article mainly gives a brief introduction to the use of React's state attributes and component verification and reuse. You can download the software. After downloading, go through Navigate to the current folder in the command panel, then execute npm install to install all environments. After the installation is complete, execute webpack –watch and the project will be ready to run.
This article ends here (if you want to see more, go to the PHP Chinese website React User Manual column to learn). If you have any questions, you can leave a message below.
The above is the detailed content of What are the React properties? Detailed explanation on the use of react attributes, events and sharing. For more information, please follow other related articles on the PHP Chinese website!