React JS / Local State Management

State Management in React JS — Part I

Local State Management in React JS

Local State Management in React JS
Local State Management in React JS
Local State Management in React JS

What is State Management?

Local State Management

Local State Management in React class components
// Defining state
this.state={
key: "value" // initialState
};
// Updating state
let { key } = this.state;
this.setState({
key: key + " changed" // newState
});
this.setState((state)=>{
let newValue = state.key + " changed"
return {
key: newValue
}
})
State variable outside the constructor
State variable inside the constructor
<span>{this.state.key}</span>
Local State Management in React function components
// Defining State
const [state, setState] = useState(initialState);
// Updating State
setState(newState);

Keen to learn new technologies !!