React Quiz on how useState works 1/2 ⚛️

Q: If we call the `increment` function once, what will be the value of `counter` in the next render?

Choose your answer using the poll in the thread!

#reactjs #CodeNewbie #100DaysOfCode #javascript #CodeNewbies

... 🧵
📊
The answer can be found in this CodeSandbox

👉 https://codesandbox.io/s/counter-1-gjvzt?file=/src/App.js

But wait, don't leave, there's still another question 👇
React Quiz on how useState works 2/2 ⚛️

Same question but different code! What will happen now?

Q: If we call the `increment` function once, what will be the value of `counter` in the next render?
📊
The answer can be found in this CodeSandbox

👉 https://codesandbox.io/s/counter-2-5spji?file=/src/App.js

...
Hope you liked it!

Follow me if you want to learn more about React, JavaScript or the web in general 😊
You may also want to check out this schema to see what's going on with these setCounter calls 😉

Built with @excalidraw
You can follow @HorusGoul.
Tip: mention @twtextapp on a Twitter thread with the keyword “unroll” to get a link to it.

Latest Threads Unrolled: