Tuesday, 31 January 2017

What is a state? How to use state?

State handles data changes. State is a JavaScript object that lives inside each component. We can access it via this.state. In React we modify the DOM indirectly, by updating each component's state and letting React handle updates to the DOM.
The state is a vital part of React apps, making user interfaces interactive. Represents data that changes over time.
We declare an initial state in the component's constructor. As first line call the super function. (To communicate with other components). In order to create the initial state for a component, we must declare the property this.state as an object in the class constructor function.
We update state by calling this.setState(), this causes our component to re-render.


WHAT OTHERS ARE READING/RELATED TO THIS:

0 comments:

Post a Comment