1//You need to use useEffect hook to achieve this.
2
3const [counter, setCounter] = useState(0);
4
5const doSomething = () => {
6 setCounter(123);
7}
8
9useEffect(() => {
10 console.log('Do something after counter has changed', counter);
11}, [counter]);
12