State

State is similar to props, but it is private and fully controlled by the component.
link - channel9.msdn.com/Shows/Web-Wednesday/How-do-I-work-with-state-in-React


interface IState_BETClass { 
  sItems: IListItem[]
}

States should only be used attributes that need to change
A parent can pass in props to set the default values for the state during construction.


The state is a property of the component
It is usually initialized in the constructor


  constructor(props) { 
    super(props);
    this.state = {date: new Date()};
  }

setState Method

It can be updated using the setState method.




© 2024 Better Solutions Limited. All Rights Reserved. © 2024 Better Solutions Limited TopPrevNext