I am trying to update the state with a localStorage value in DidMount, but it is not updating:
type Props = { }; type State = { id_evaluation: string, }; c
That is because you call console.log before the state has updated. Try this:
this.setState({ id_evaluation: '1', }, () => { console.log('2 - ', this.state.id_evaluation); });
See this thread:
Can I execute a function after setState is finished updating?