React setState status change

  addEditChange(e,key){
        let that = this;
        let add_edit_form = that.state.add_edit_form;
            add_edit_form[key] = e.target.value;
        that.setState({
            add_edit_form:add_edit_form
        })
        console.log(that.state.budget_form);
    }
    
    
     setState  add_edit_form  budget_form
    
Mar.02,2021

is your budget_form add_edit_form


console.log(that.state.budget_form);  
that.setState({
            add_edit_form:add_edit_form
},()=>{
 console.log(that.state.budget_form);    
})

see if the print is the same


typical shallow copy and deep copy (somewhere add_edit_form equals budget_form), if you want to change it, you'd better use

.
import update from 'react-addons-update';

...

const add_edit_form = update(budget_form, {a: {$set: 'b'}})
//
const add_edit_form = update(this.state.add_edit_form, {a: {$set: 'b'}})
//add_edit_formreference

this.setState({add_edit_form})
Menu