We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Please see a code underneath. The expected and actual results are given below. Please help to understand the reason for the differences.
React version: React 18
Please run the sample code below.
import { useEffect, useState } from 'react'; export default function App() { const [counter, setCounter] = useState(null); useEffect(() => { let i = 0; setTimeout(() => { setCounter((c) => { console.log(c, i); return i; }); i = i + 1; setTimeout(() => { setCounter((c) => { console.log(c, i); return i; }); i = i + 1; setTimeout(() => { setCounter((c) => { console.log(c, i); return i; }); i = i + 1; }, 500); }, 500); }, 500); }, []); return <>{counter && counter}</>; }
In browser :
// 0/2/3
In console :
/* null,0 0,2 2,3 */
// 1/2/3 (each digit delayed by half of a second)
/* null,1 1,2 2,3 */
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Please see a code underneath. The expected and actual results are given below. Please help to understand the reason for the differences.
React version: React 18
Steps To Reproduce
Please run the sample code below.
The current behavior
In browser :
// 0/2/3
In console :
The expected behavior
In browser :
// 1/2/3 (each digit delayed by half of a second)
In console :
The text was updated successfully, but these errors were encountered: