Showing posts with label React State. Show all posts
Showing posts with label React State. Show all posts
React State

React State

React sees the component as a state machine. Through the interaction with the user to achieve a different state, and then render the UI, so that the user interface and data consistent.
React, just update the state of the component, and then re-render the user interface according to the new state (do not manipulate the DOM).
The LikeButton component is created in the following example, and the getInitialState method is used to define the initial state, that is, an object that can be read by this.state property. When the user clicks on the component, causing the state to change, the this.setState method modifies the state value. After each modification, the this.render method is called automatically and the component is rendered again.

React instance

I. I switch the state. </ P > ) ; } }); ReactDOM . Render ( < LikeButton />, document . GetElementById ( ' example ' ) ) ;

try it"

Popular Posts