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

python - Operations inside variables -

Generic Map Parameter java -

arrays - What causes a java.lang.ArrayIndexOutOfBoundsException and how do I prevent it? -