Passing a function to setState

    0

    0

    majid ghasemi

    Library: react

    this.setState((prevState, props) => ({
      count: prevState.count + props.increment
    }));
    
    this.setState(prevState => ({ expanded: !prevState.expanded }));
    Codiga Logo
    Codiga Hub
    • Rulesets
    • Playground
    • Snippets
    • Cookbooks
    soc-2 icon

    We are SOC-2 Compliance Certified

    G2 high performer medal

    Codiga – All rights reserved 2022.