Answer the question
In order to leave comments, you need to log in
Function instead of object in setState?
I came across an article on React, which describes the benefits of changing state with a function call.
There is a structure like this:
submit(){
this.setState(function(prevState, props){
return {showForm: !prevState.showForm}
});
}
Answer the question
In order to leave comments, you need to log in
The presence of a function argument does not force it to be used. This is done so that, if desired, you can refer to the properties.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question