LEARN REACT_ ADDING INTERACTIVITY_ Queueing a Series of State Updates ๐Ÿ‘‰ state update๋Š” ์–ด๋–ป๊ฒŒ ์ด๋ฃจ์–ด์งˆ๊นŒ?

์„œ์ •์ค€ยท2023๋…„ 7์›” 3์ผ
0

react.dev

๋ชฉ๋ก ๋ณด๊ธฐ
4/5

์ถœ์ฒ˜: React doc

React batches state updates

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"๋Š” ์ผ๋ จ์˜ ์ž‘์—…์„ ๋ชจ์•„์„œ ํ•œ๊บผ๋ฒˆ์— ์‹คํ–‰ํ•˜๊ฑฐ๋‚˜ ์ฒ˜๋ฆฌํ•˜๋Š” ๋ฐฉ์‹์„ ๊ฐ€๋ฆฌํ‚ต๋‹ˆ๋‹ค.
profile
ํ†ตํ†ตํ†ตํ†ต

0๊ฐœ์˜ ๋Œ“๊ธ€