I'm trying to understand this weird behavior:
const [counter, setCounter] = useState<number>(1);
useEffect(() => {
setCounter(2);
setTimeout(function () {
console.log('counter = ', counter); // => counter = 1
}, 1000);
}, []);