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

'hasOwnProperty' in javascript -

How to put a lock and transaction on table using spring 4 or above using jdbcTemplate and annotations like @Transactional? -

How to understand 2 main() functions after using uftrace to profile the C++ program? -