this.setState({ name: "Hello Chris1993!" }, () => {
console.log(this.state.name); // output: Hello Chris1993!
});
console.log(this.state.name); // output: Hello Chris1993!
});
For Functional Component Use useEffect.
useEffect(() => {
console.log(state) // do something after state has updated
}, [state])