Wednesday, June 24, 2020

React Native Components - State

                                                                   State

There are two types of data that control components - State & Props. Anything that changes over time is known as state. If we had a Counter app, the state would be the Counter itself. we can initialize state in the constructor, and then call setState when we want to change it. The data inside react component is managed by State & Props. The component that uses state is mutable.they can be changed later on if  required.

example:
In this example, we create Text component with state data.this data updated when we click on text.The event onPress call in setState. using setState we update the data. 

Output:

The state is updated.

Previous Post
Next Post

post written by:

Hello guys, myself Pooja Tirmare. I want to share my knowledge with people so they can learn react native and make beautiful applications.