Reactjs setstate by field -


in react js component have code

this.state.author[field] = value; 

in console got warning: not mutate state directly. use setstate()

how put author [] in setstate?

if field variable holds key, can this:

this.setstate({author: {...this.state.author, [field]: value}}) 

Comments

Popular posts from this blog

sql - Time in datatime field -

javascript - How to split the success output from an Ajax post? -

java - sharing object across different classes -