javascript - Set multiple states in setState - React.js ES6 -
how add name const second setstate method? in order increment currentcompany must include prevstate. when attempt add name const not work.
const name = company.word; this.setstate({ name }); this.setstate(prevstate => ({ currentcompany: (prevstate.currentcompany + 1) }));
thank :)
you can write also:
this.setstate({ name , currentcompany: this.state.currentcompany + 1 })
multiple setstate
within function not idea, try calculation use setstate
once after that.
Comments
Post a Comment