Thursday, September 19, 2019

React: Best practice to setState when setting the value based on previous state

There is another interface to sue

this.setState( (prevState,props)=>{
    return {
        posts: posts,
        counter: prevState.counter + 1
    }
});

No comments:

Post a Comment