Why we use state in React instead of variable?
Though using state may seem similar to class variable but state is a protected keyword in React that refers to stored component data . The major difference between using class variables and state is updating data. Instead of manually reassigning the variable, you call this. setState() .
Read moreWhat is the use of state in React?
React components has a built-in state object. The state object is where you store property values that belongs to the component . When the state object changes, the component re-renders.
Read more