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,
};
class Evaluation extends Component < Props, State > {
state = {
id_evaluation: '',
}
componentDidMount() {
const id_eval = getEvaluation();
console.log('1 - ', id_eval)
this.setState({
id_evaluation: '1',
});
console.log('2 - ', this.state.id_evaluation)
In the first console.log I have the value 1, in the second it remains empty, it does not update the state.