This solution is generated by ChatGPT, correctness is not guaranteed. You might also be able to find a solution fromcommunity posts.
AI solution for React Quiz on BFE.dev
5. Automatic batching 1
The code will output "App 2" in the console. This is because the useState
hook initializes state
to 0
, and then the button's onClick handler calls setState
twice - first adding 1 to the current value of state
, which updates it to 1, and then multiplying that value by 2, which updates it to 2. The console.log
statement inside the App
component then logs the updated value of state
, which is 2.