์ถ์ฒ: React doc
React waits until all code in the event handlers has run before processing your state updates. This is why the re-render only happens after all these setNumber() calls.
This might remind you of a waiter taking an order at the restaurant. A waiter doesnโt run to the kitchen at the mention of your first dish! Instead, they let you finish your order, let you make changes to it, and even take orders from other people at the table.
๐ react๋ state update๋ฅผ ํ๋ฒ์ ๋ชจ์์ ์ฒ๋ฆฌํ๋ค.
์ฌ์
(์ถ์ฒ: Chat GPT)
- batches
๋จ์ด๋ ์ผ๋ฐ์ ์ผ๋ก ํ ๋ฒ์ ๋ชจ์์ ์ฒ๋ฆฌํ๋ ๊ฒ์ ์๋ฏธํฉ๋๋ค. ์ปดํจํฐ ๊ณผํ ๋ฐ ์ํํธ์จ์ด ๊ฐ๋ฐ์ ๋งฅ๋ฝ์์ "batch"๋ ์ผ๋ จ์ ์์ ์ ๋ชจ์์ ํ๊บผ๋ฒ์ ์คํํ๊ฑฐ๋ ์ฒ๋ฆฌํ๋ ๋ฐฉ์์ ๊ฐ๋ฆฌํต๋๋ค.