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

Popular posts from this blog

Command prompt result in label. Python 2.7 -

javascript - How do I use URL parameters to change link href on page? -

amazon web services - AWS Route53 Trying To Get Site To Resolve To www -