I use this in a setInterval and it feels very illegal
const [nonce, setNonce] = useState(0);
useEffect(() => {
window.setInterval(() => {
let nonce = 0;
setNonce((prevNonce) => (nonce = prevNonce));
console.log('nonce has the correct value even if got changed:', nonce);
}, 10);
}, []);
Is this something I should not use?