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

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -