Answers for "setstate with prevstate react"

2

prevstate in usestate

const [prevState, setState] = React.useState([]);

setState(prevState => [...prevState, 'somedata'] );
Posted by: Guest on June-09-2020
0

prevstate in react

handleClick() {
        this.setState(prevState => {
            return {
                count: prevState.count + 1
            }
        })
    }
Posted by: Guest on May-06-2020

Code answers related to "setstate with prevstate react"

Code answers related to "Javascript"

Browse Popular Code Answers by Language