I know how to do this in class components but when i use same code in functional component i get an error. This is what i want -
this.setState({cnt:this.state.cnt+1})
alert(this.state.cnt);
now i want the alert to show count as 1 . How we do it in class component -
this.setState({cnt:this.state.cnt+1}, () => alert(this.state.cnt));
But when i do same in functional component like this
const[count, setCount] = useState(0);
setCount(count+1, () => alert(count));
I get an error - "expected no of arguments - 1".