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
Post a Comment