score:0

Accepted answer

state update in react is asynchronous, so you should not expect updated values in the next statement itself. instead you can try something like(logging updated state in setstate callback):

    this.setstate({
     todoitems: {newtodoitems},// also i doubt this statement as well, shouldn't it be like:  todoitems: newtodoitems ? 
    },()=>{
       //callback from state update
       console.log(this.state.todoitems);
    })

Related Query

More Query from same tag