diff --git a/June/article/How-React-19-(Almost)-Made-the-Internet-Slower.md b/June/article/How-React-19-(Almost)-Made-the-Internet-Slower.md new file mode 100644 index 0000000..120ec46 --- /dev/null +++ b/June/article/How-React-19-(Almost)-Made-the-Internet-Slower.md @@ -0,0 +1,186 @@ +# [How React 19 (Almost) Made the Internet Slower](https://blog.codeminer42.com/how-react-19-almost-made-the-internet-slower/?utm_source=newsletter.reactdigest.net&utm_medium=referral&utm_campaign=react-19-and-suspense) + +### ๐Ÿ—“๏ธ ๋ฒˆ์—ญ ๋‚ ์งœ: 2024.06.26 + +### ๐Ÿงš ๋ฒˆ์—ญํ•œ ํฌ๋ฃจ: ๋งˆ์Šคํ„ฐ์œ„(๋ช…์žฌ์œ„) + +--- + +Henrique Yuji +Updated On Jun 17, 2024 +Keyword : **Frontend**, **React** + +๋ฆฌ์•กํŠธ(React)๋Š” ์—ฌ์ „ํžˆ [๊ฐ€์žฅ ์ธ๊ธฐ ์žˆ๊ณ  ๋„๋ฆฌ ์‚ฌ์šฉ๋˜๋Š”](https://gist.github.com/tkrotoff/b1caa4c3a185629299ec234d2314e190) ์‚ฌ์šฉ๋˜๋Š” UI ํ”„๋ ˆ์ž„์›Œํฌ๋กœ, ๋„ทํ”Œ๋ฆญ์Šค, ์—์–ด๋น„์•ค๋น„, ๋””์Šค์ฝ”๋“œ, ๋ฉ”ํƒ€(ํŽ˜์ด์Šค๋ถ, ์ธ์Šคํƒ€๊ทธ๋žจ, ์™“์ธ ์•ฑ) ๋“ฑ ๋Œ€ํ˜• ์›น์‚ฌ์ดํŠธ์—์„œ ์‚ฌ์šฉ๋ฉ๋‹ˆ๋‹ค. ์ˆ˜์‹ญ์–ต ๋ช…์ด ์‚ฌ์šฉํ•˜๋Š” ์‚ฌ์šฉ์ž ์ธํ„ฐํŽ˜์ด์Šค๋ฅผ ๋งŒ๋“œ๋Š” ๋ฐ ์‚ฌ์šฉ๋˜๋ฏ€๋กœ, ์ธํ„ฐ๋„ท ํŠธ๋ž˜ํ”ฝ์˜ ์ƒ๋‹น ๋ถ€๋ถ„์ด React์— ์˜ํ•ด ์ฒ˜๋ฆฌ๋œ๋‹ค๊ณ  ๋ณผ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. + +์˜ฌํ•ด ์ดˆ ๋ฐœํ‘œ๋œ ๊ธฐ๋Œ€๋ฅผ ๋ชจ์•˜๋˜ React 19๋Š” ๋งŽ์€ ์ƒˆ๋กœ์šด ๊ธฐ๋Šฅ๊ณผ ๊ฐœ๋ฐœ์ž ๊ฒฝํ—˜(DX) ๊ฐœ์„ ์„ ํฌํ•จํ•˜๊ณ  ์žˆ์ง€๋งŒ, ์ตœ๊ทผ๊นŒ์ง€ ์ฃผ๋ชฉ๋ฐ›์ง€ ๋ชปํ•œ ์ž‘์€ ๋ณ€๊ฒฝ ์‚ฌํ•ญ์ด ์žˆ์—ˆ์Šต๋‹ˆ๋‹ค. ์ด๋Š” ์—ฌ๋Ÿฌ React ๊ธฐ๋ฐ˜ ์›น์‚ฌ์ดํŠธ์˜ ์„ฑ๋Šฅ์„ ํฌ๊ฒŒ ์ €ํ•˜์‹œํ‚ฌ ์ˆ˜ ์žˆ๋Š” ์ž ์žฌ๋ ฅ์„ ๊ฐ€์ง€๊ณ  ์žˆ์—ˆ์Šต๋‹ˆ๋‹ค. + +๋ชจ๋“  ๊ฒƒ์€ ๋‹ค์Œ ํŠธ์œ—์—์„œ ์‹œ์ž‘๋˜์—ˆ์Šต๋‹ˆ๋‹ค: + + + +[@TkDodo](https://x.com/TkDodo/status/1800501040766144676): "๋‚ด๊ฐ€ ์ƒ์ƒํ•˜๋Š” ๊ฑด๊ฐ€์š”, ์•„๋‹ˆ๋ฉด React 18๊ณผ 19์—์„œ Suspense๊ฐ€ ๋ณ‘๋ ฌ ํŽ˜์นญ์„ ์ฒ˜๋ฆฌํ•˜๋Š” ๋ฐฉ์‹์— ์ฐจ์ด๊ฐ€ ์žˆ๋‚˜์š”? 18์—์„œ๋Š” ๊ฐ ์ปดํฌ๋„ŒํŠธ๊ฐ€ ๋ณ‘๋ ฌ๋กœ ๋ถ„๋ฆฌ๋˜์—ˆ์ง€๋งŒ, 19์—์„œ๋Š” ์—ฐ์†์ ์œผ๋กœ ์‹คํ–‰๋˜๋Š” ๊ฒƒ ๊ฐ™์Šต๋‹ˆ๋‹ค." +์ด๋Š” ๋‘ ๊ฐœ์˜ ์ฟผ๋ฆฌ๋ฅผ ๋ณ‘๋ ฌ๋กœ ์‹คํ–‰ํ•˜๊ณ , ๋‘˜ ๋‹ค ํ•ด๊ฒฐ๋  ๋•Œ๊นŒ์ง€ ๊ธฐ๋‹ค๋ฆฐ ๋‹ค์Œ ์ „์ฒด ์„œ๋ธŒ ํŠธ๋ฆฌ๋ฅผ ๋ณด์—ฌ์ค๋‹ˆ๋‹ค. +React 19์—์„œ๋Š” ๋‚ด๊ฐ€ ๋ณด๊ธฐ์—” ์ฟผ๋ฆฌ๋“ค์ด ์ด์ œ ํญํฌ์ˆ˜์ฒ˜๋Ÿผ ์‹คํ–‰๋ฉ๋‹ˆ๋‹ค. @rickhanlonii๊ฐ€ ์ด๋Ÿฐ ์–˜๊ธฐ๋ฅผ ํ–ˆ๋˜ ๊ฒƒ ๊ฐ™์€๋ฐ ์ง€๊ธˆ์€ evidence๋ฅผ ์ฐพ์„ ์ˆ˜ ์—†์Šต๋‹ˆ๋‹ค. + +--- + + + +[@AdamRackis](https://x.com/AdamRackis/status/1800588094560772224) : ์ด๋Š” ์ดํ•ดํ•  ์ˆ˜ ์—†๋Š”, ๋ฏธ์นœ ๋ณ€ํ™”์ž…๋‹ˆ๋‹ค. ๋Œ“๊ธ€์— ๋”ฐ๋ฅด๋ฉด ํด๋ผ์ด์–ธํŠธ ์ปดํฌ๋„ŒํŠธ์— ์ ์šฉ๋˜๋Š” ๊ฒƒ ๊ฐ™์Šต๋‹ˆ๋‹ค๋งŒ, ๋ณ‘๋ ฌ ํŽ˜์นญ์€ ์—ฌ์ „ํžˆ RSC์—์„œ ์ž‘๋™ํ•ฉ๋‹ˆ๋‹ค. +์ด๋Š” react-query๋ฅผ ๋ง์น˜๋ฉฐ, React๋กœ ๋ฐ์ดํ„ฐ๋ฅผ ๊ด€๋ฆฌํ•˜๋Š” ์œ ์ผํ•œ ์ข‹์€ ๋ฐฉ๋ฒ•์ž…๋‹ˆ๋‹ค. +๋ƒ‰์ •ํ•œ ํŒ๋‹จ์ด ์žˆ๊ธฐ๋ฅผ ๋ฐ”๋ผ์ง€๋งŒ, ๊ทธ๋Ÿฌ์ง€ ์•Š์„ ๊ฒƒ ๊ฐ™๋„ค์š”. + +--- + + + +@TkDodo : ์ด์ œ ํ™•์‹คํžˆ React 19์˜ suspense์™€ ํ˜•์ œ ์‚ฌ์ „ ๋ Œ๋”๋ง ๋ณ€๊ฒฝ ์‚ฌํ•ญ์— ๋Œ€ํ•ด ๋ธ”๋กœ๊ทธ์— ์จ์•ผ๊ฒ ์–ด์š”. React ํ•ต์‹ฌ ํŒ€ ์™ธ์—๋Š” ์ด ๊ฑฐ๋ž˜๊ฐ€ ์˜ณ๋‹ค๊ณ  ์ƒ๊ฐํ•˜๋Š” ์‚ฌ๋žŒ์„ ์•„์ง ๋ณธ ์ ์ด ์—†์–ด์š”. v19.0.0์€ ์•„์ง ์ถœ์‹œ๋˜์ง€ ์•Š์•˜์œผ๋‹ˆ, ๊ทธ๋“ค์„ ์žฌ๊ณ ํ•˜๋„๋ก ํ•  ์ˆ˜ ์žˆ๋Š” ๊ฐ€๋Šฅ์„ฑ์ด ์žˆ์„์ง€๋„ ๋ชฐ๋ผ์š”. + +--- + +[@tannerlinsley](https://x.com/tannerlinsley/status/1800903098464096664) : "๊ทธ๋ž˜์š”, ์ด๊ฑด ๋‚˜์œ ๊ฒฐ์ •์ฒ˜๋Ÿผ ๋Š๊ปด์ ธ์š”, ํŠนํžˆ ๊ธฐ์กด ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜๊ณผ ์‚ฌ์šฉ ์‚ฌ๋ก€๋ฅผ ์ž๋™์œผ๋กœ ๋” ๋‚˜์˜๊ฒŒ ๋งŒ๋“ค๊ธฐ ๋•Œ๋ฌธ์—." + +--- + + + +[@AdamRackis](https://x.com/AdamRackis/status/1800663066922963264) : ์ €๋Š” ๊ฐ„์ ˆํžˆ ๋ฐ”๋ผ๊ฑด๋Œ€ Vercel, ๊ทธ๋ฆฌ๊ณ  ์ด์ œ๋Š” ๋”์šฑ ์šฐ๋ ค๋˜๋Š” *React ํ•ต์‹ฌ ํŒ€*์ด ๋ชจ๋“  ์‚ฌ๋žŒ์ด ์ฝ˜ํ…์ธ ๋ฅผ ๊ฐ€๋Šฅํ•œ ๋นจ๋ฆฌ ์•ž์— ๋ณด์—ฌ์ฃผ์–ด ์ง€๋ฃจํ•œ ์‚ฌ์šฉ์ž๊ฐ€ ๋’ค๋กœ ๊ฐ€๊ธฐ ๋ฒ„ํŠผ์„ ๋ˆ„๋ฅด์ง€ ์•Š๋„๋ก ํ•˜๋Š” ๊ฒƒ์ด ์ตœ์šฐ์„ ์ธ ์ „์ž ์ƒ๊ฑฐ๋ž˜ ์‚ฌ์ดํŠธ๋ฅผ ๋ฐฐํฌํ•˜๋Š” ๊ฒƒ์€ ์•„๋‹ˆ๋ผ๋Š” ์ ์„ ์ดํ•ดํ•˜๊ธฐ๋ฅผ ๋ฐ”๋ž๋‹ˆ๋‹ค. + +--- + +
+ +๋„๋ฏธ๋‹‰(TkDodo)์„ ๋ชจ๋ฅด๋Š” ๋ถ„๋“ค์„ ์œ„ํ•ด ์„ค๋ช…ํ•˜์ž๋ฉด, ๊ทธ๋Š” ๋„๋ฆฌ ์‚ฌ์šฉ๋˜๋Š” TanStack Query์˜ ์ฃผ์š” ์œ ์ง€ ๊ด€๋ฆฌ์ž ์ค‘ ํ•œ ๋ช…์ด๋ฉฐ, ์ „์„ค์ ์ธ ํƒœ๋„ˆ ๋ฆฐ์ฆ๋ฆฌ(Tanner Linsley)์™€ ํ•จ๊ป˜ ์ผํ•˜๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค. + +ํ•˜์ง€๋งŒ ๋‹ค์‹œ ๋ณธ๋ก ์œผ๋กœ ๋Œ์•„๊ฐ€์„œ, ์—ฌ๊ธฐ์„œ ๋…ผ์˜๋˜๋Š” ๋ณ€๊ฒฝ ์‚ฌํ•ญ์€ React 19์—์„œ ๋™์ผํ•œ Suspense ๊ฒฝ๊ณ„ ๋‚ด ํ˜•์ œ ์š”์†Œ์˜ ๋ณ‘๋ ฌ ๋ Œ๋”๋ง์„ ๋น„ํ™œ์„ฑํ™”ํ•œ๋‹ค๋Š” ๊ฒƒ์ž…๋‹ˆ๋‹ค. ์ด๋Š” ํ˜•์ œ ์š”์†Œ ๋‚ด๋ถ€์—์„œ ๊ฐ€์ ธ์˜ค๋Š” ๋ฐ์ดํ„ฐ์— ๋Œ€ํ•œ ๋ฐ์ดํ„ฐ ํŽ˜์นญ ํญํฌ์ˆ˜๋ฅผ ๋„์ž…ํ•˜๊ฒŒ ๋ฉ๋‹ˆ๋‹ค. + +๋‹ค์Œ์€ ๊ทธ ์˜ˆ์‹œ์ž…๋‹ˆ๋‹ค: + + + + + +๊ฐ€์žฅ ํฐ ๋ฌธ์ œ๋Š” ์ด ๋ณ€ํ™”๊ฐ€ ์„ฑ๋Šฅ ์ธก๋ฉด์—์„œ ์ค‘์š”ํ•œ ๋ณ€๊ฒฝ ์‚ฌํ•ญ์ด์ง€๋งŒ, ์ด ํŒจํ„ด์— ์˜์กดํ•˜๋Š” ๋งŽ์€ ์‚ฌ๋žŒ๋“ค์—๊ฒŒ ์˜ํ–ฅ์„ ๋ฏธ์น  ๊ฒƒ์ด๋ผ๋Š” ์ ์ž…๋‹ˆ๋‹ค. ๊ทธ๋Ÿผ์—๋„ ๋ถˆ๊ตฌํ•˜๊ณ  ์ด ๋ณ€๊ฒฝ ์‚ฌํ•ญ์ด ๋‹จ ํ•œ ์ค„์˜ ๋ถˆ๋ช…ํ™•ํ•œ ๊ธ€๋จธ๋ฆฌ๋กœ ์–ธ๊ธ‰๋˜์—ˆ๋‹ค๋Š” ์ ์ž…๋‹ˆ๋‹ค. + + + +์ œ๊ฐ€ ๋ฐฉ๊ธˆ ๋งํ•œ ๋‚ด์šฉ์ด ํ—ท๊ฐˆ๋ฆฌ์…จ๋‹ค๋ฉด, ๋‹น์‹ ๋งŒ ๊ทธ๋Ÿฐ ๊ฒƒ์ด ์•„๋‹™๋‹ˆ๋‹ค. ์ €๋„ ์ฒ˜์Œ ์ด ๊ธ€์„ ์ ‘ํ–ˆ์„ ๋•Œ ๊ทธ๋ ‡๊ฒŒ ๋Š๊ผˆ์Šต๋‹ˆ๋‹ค. ๊ฑฑ์ •ํ•˜์ง€ ๋งˆ์„ธ์š”. ๊ณง ๋ชจ๋“  ๊ฒƒ์ด ์ดํ•ด๋  ๊ฒƒ์ž…๋‹ˆ๋‹ค. + +## Suspense ๋ณต์Šต + +์ด ๋‚ด์šฉ์„ ์ดํ•ดํ•˜๋ ค๋ฉด ๋จผ์ € React์˜ Suspense์— ๋Œ€ํ•ด ๊ฐ„๋žตํžˆ ๋ณต์Šตํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค. + +Suspense๋Š” ์ž์‹ ์ปดํฌ๋„ŒํŠธ๊ฐ€ ๋กœ๋”ฉ์„ ๋งˆ์น  ๋•Œ๊นŒ์ง€ ๋Œ€์ฒด ๋‚ด์šฉ์„ ํ‘œ์‹œํ•  ์ˆ˜ ์žˆ๊ฒŒ ํ•˜๋Š” React ์ปดํฌ๋„ŒํŠธ์ž…๋‹ˆ๋‹ค. ์ž์‹ ์ปดํฌ๋„ŒํŠธ๊ฐ€ ์ง€์—ฐ ๋กœ๋“œ๋˜๊ฑฐ๋‚˜, Suspense๋ฅผ ์‚ฌ์šฉํ•œ ๋ฐ์ดํ„ฐ ํŽ˜์นญ ๋ฉ”์ปค๋‹ˆ์ฆ˜์„ ์‚ฌ์šฉํ•  ๋•Œ ์œ ์šฉํ•ฉ๋‹ˆ๋‹ค. + +์‚ฌ์šฉ ์˜ˆ์‹œ๋Š” ๋‹ค์Œ๊ณผ ๊ฐ™์Šต๋‹ˆ๋‹ค: + +```jsx +}> + + +``` + +Suspense๋Š” ์˜ค๋žซ๋™์•ˆ React API์˜ ์ผ๋ถ€์˜€์ง€๋งŒ, ๊ณต์‹์ ์œผ๋กœ ์Šน์ธ๋œ ์‚ฌ์šฉ๋ฒ•์€ React.lazy์™€ ํ•จ๊ป˜ ์ง€์—ฐ ๋กœ๋”ฉ์„ ์‚ฌ์šฉํ•˜๋Š” ๊ฒƒ์ด์—ˆ์Šต๋‹ˆ๋‹ค. ์ด๋Š” ์•ฑ์„ ์ฝ”๋“œ ๋ถ„ํ• ํ•˜๊ณ  ํ•„์š”ํ•œ ๊ฒฝ์šฐ์—๋งŒ ๋ถ„ํ• ๋œ ๋ถ€๋ถ„์„ ๋กœ๋“œํ•˜๋Š” ๋ฐ ๋งค์šฐ ์œ ์šฉํ•ฉ๋‹ˆ๋‹ค. + +React.lazy๋ฅผ ์‚ฌ์šฉํ•˜๋ฉด ์ฒ˜์Œ ์ง€์—ฐ ๋กœ๋“œ๋œ ์ปดํฌ๋„ŒํŠธ๋ฅผ ๋ Œ๋”๋งํ•˜๋ ค๊ณ  ํ•  ๋•Œ Suspense ๊ฒฝ๊ณ„๋ฅผ ํŠธ๋ฆฌ๊ฑฐํ•˜๊ณ , ์ปดํฌ๋„ŒํŠธ ์ฝ”๋“œ๋ฅผ ๊ฐ€์ ธ์˜ฌ ๋•Œ๊นŒ์ง€ ๋Œ€์ฒด ๋‚ด์šฉ์„ ๋ Œ๋”๋งํ•œ ๋‹ค์Œ ์ปดํฌ๋„ŒํŠธ ์ž์ฒด๋ฅผ ๋ Œ๋”๋งํ•ฉ๋‹ˆ๋‹ค. + +์˜ค๋žซ๋™์•ˆ ํด๋ผ์ด์–ธํŠธ ์ธก์—์„œ Suspense๋ฅผ ์œ„ํ•œ ๊ณต์‹ ๋ฐ์ดํ„ฐ ํŽ˜์นญ ์ง€์›์ด ์•ฝ์†๋˜์—ˆ์ง€๋งŒ, ์ง€๊ธˆ๊นŒ์ง€ ์‹คํ˜„๋˜์ง€ ์•Š์•˜์Šต๋‹ˆ๋‹ค. ๊ทธ๋Ÿผ์—๋„ ๋ถˆ๊ตฌํ•˜๊ณ  ๋งŽ์€ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ(์˜ˆ: TanStack Query)๋Š” React ๋‚ด๋ถ€๋ฅผ ์กฐ์‚ฌํ•˜์—ฌ ์ด๋ฅผ ๊ตฌํ˜„ํ–ˆ์Šต๋‹ˆ๋‹ค. ๊ฒฐ๊ณผ์ ์œผ๋กœ ํ˜„์žฌ ๋งŽ์€ ํ”„๋กœ๋•์…˜ ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์ด ํด๋ผ์ด์–ธํŠธ ์ธก ๋ฐ์ดํ„ฐ ํŽ˜์นญ์— Suspense๋ฅผ ์‚ฌ์šฉํ•˜๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค. + +## ๋ณ€ํ™” ์ดํ•ดํ•˜๊ธฐ + +ํ˜„์žฌ(React 18.3.1 ๊ธฐ์ค€) ๋™์ผํ•œ Suspense ๊ฒฝ๊ณ„ ๋‚ด์—์„œ ์—ฌ๋Ÿฌ ์ปดํฌ๋„ŒํŠธ์™€ ํ•จ๊ป˜ Suspense ์ง€์› ๋ฐ์ดํ„ฐ ํŽ˜์นญ ๋˜๋Š” ์ง€์—ฐ ๋กœ๋”ฉ์„ ์‚ฌ์šฉํ•  ๋•Œ, React๋Š” ์ฒซ ๋ฒˆ์งธ ํ˜•์ œ ์ปดํฌ๋„ŒํŠธ๊ฐ€ ์ค‘๋‹จ๋˜๋”๋ผ๋„ ๋ชจ๋“  ํ˜•์ œ๋ฅผ ๋ Œ๋”๋งํ•˜๋ ค๊ณ  ์‹œ๋„ํ•ฉ๋‹ˆ๋‹ค. + +์‹ค์ œ๋กœ ์ด๋Š” ์ด๋Ÿฌํ•œ ํ˜•์ œ ์ปดํฌ๋„ŒํŠธ ๋‚ด์—์„œ ๋ฐœ์ƒํ•˜๋Š” ๋ฐ์ดํ„ฐ ํŽ˜์นญ ๋˜๋Š” ์ง€์—ฐ ๋กœ๋”ฉ์ด ๋ชจ๋‘ ๋ณ‘๋ ฌ๋กœ ์‹œ์ž‘๋œ๋‹ค๋Š” ๊ฒƒ์„ ์˜๋ฏธํ•ฉ๋‹ˆ๋‹ค. + +์ด ์ƒ๊ฐ์— ๋Œ€ํ•œ ์˜ˆ์‹œ๋ฅผ ๋ณด์‹œ์ฃ  : + +```jsx +function App() { + return ( + <> + + + + + + + ); +} + +const ComponentThatFetchesData = ({ val }) => { + const result = fetchSomethingSuspense(val); + + return
{result}
; +}; +``` + +Demo: https://stackblitz.com/edit/vitejs-vite-x3nv7r?file=src%2FApp.jsx + +์ด ์˜ˆ์‹œ์—์„œ๋Š” (React 18์—์„œ) `fetchSomethingSuspense`๊ฐ€ ์ฒซ ๋ฒˆ์งธ `ComponentThatFetchesData`๋ฅผ ์ค‘๋‹จ์‹œ์ผœ๋„, React๋Š” ์—ฌ์ „ํžˆ ํ˜•์ œ ์ปดํฌ๋„ŒํŠธ๋ฅผ ๋ Œ๋”๋งํ•˜๋ ค๊ณ  ์‹œ๋„ํ•˜์—ฌ ๊ฐ๊ฐ์˜ ๋ฐ์ดํ„ฐ ํŽ˜์นญ์ด ๋ณ‘๋ ฌ๋กœ ์‹œ์ž‘๋ฉ๋‹ˆ๋‹ค. + +์ด๋ฅผ ํ™•์ธํ•˜๊ธฐ ์œ„ํ•ด ์ฝ˜์†”์—์„œ ๊ฐ ๋ฐ์ดํ„ฐ ํŽ˜์นญ์ด ์–ธ์ œ ํŠธ๋ฆฌ๊ฑฐ๋˜๋Š”์ง€ ๋กœ๊ทธ๋ฅผ ํ™•์ธํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค: + + + +๋ชจ๋“  ๋ฐ์ดํ„ฐ ํŽ˜์นญ์ด ๊ฑฐ์˜ ๋™์‹œ์— ์‹œ์ž‘๋ฉ๋‹ˆ๋‹ค. + +์ด์ œ ๋™์ผํ•œ ์ฝ”๋“œ๋ฅผ React 19 (canary)์—์„œ ์‹คํ–‰ํ–ˆ์„ ๋•Œ ์–ด๋–ค ์ผ์ด ๋ฐœ์ƒํ•˜๋Š”์ง€ ์‚ดํŽด๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค: + +Demo: https://stackblitz.com/edit/vitejs-vite-55rddj?file=src%2FApp.jsx + + + +์ฝ˜์†”์„ ๋‹ค์‹œ ํ™•์ธํ•ด ๋ณด๋ฉด ์ด์ œ๋Š” ํญํฌ์ˆ˜ ํ˜•ํƒœ๊ฐ€ ๋‚˜ํƒ€๋‚˜๋ฉฐ, ๊ฐ ๋ฐ์ดํ„ฐ ํŽ˜์นญ์ด ์ด์ „ ํŽ˜์นญ์ด ์™„๋ฃŒ๋œ ํ›„์—์•ผ ์‹œ์ž‘๋˜๋Š” ๊ฒƒ์„ ์•Œ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. + +์ด๊ฒƒ์€ ๋‹ค์Œ PR์—์„œ ์ผ์–ด๋‚ฌ์Šต๋‹ˆ๋‹ค : +https://github.com/facebook/react/pull/26380 + +์ด PR์— ์˜ํ•ด ๋„์ž…๋œ ๋ณ€๊ฒฝ ์‚ฌํ•ญ ์ดํ›„, React๋Š” ๋™์ผํ•œ Suspense ๊ฒฝ๊ณ„ ๋‚ด์˜ ๋ชจ๋“  ํ˜•์ œ ์š”์†Œ๋ฅผ ๋ Œ๋”๋งํ•˜๋ ค๊ณ  ์‹œ๋„ํ•˜๋Š” ๋Œ€์‹ , ์ฒซ ๋ฒˆ์งธ๋กœ ์ค‘๋‹จ๋˜๋Š” ์š”์†Œ์—์„œ ๋ฉˆ์ถ”๊ฒŒ ๋ฉ๋‹ˆ๋‹ค. ์ด๋Ÿฌํ•œ ๊ฒฝ์šฐ, ์ฒซ ๋ฒˆ์งธ ์ปดํฌ๋„ŒํŠธ๋ฅผ ๋ Œ๋”๋งํ•˜๋ ค๊ณ  ์‹œ๋„ํ•œ ํ›„ ์ค‘๋‹จ๋˜๋ฉด, ๋ฐ์ดํ„ฐ ํŽ˜์นญ์ด ์™„๋ฃŒ๋œ ํ›„์—์•ผ ๋‹ค์Œ ํ˜•์ œ ์š”์†Œ๋กœ ๋„˜์–ด๊ฐ€๊ณ , ๋‹ค์‹œ ์ค‘๋‹จ๋ฉ๋‹ˆ๋‹ค. + +์ด ์ƒˆ๋กœ์šด ๋™์ž‘์€ ๋ฐ์ดํ„ฐ ํŽ˜์นญ์„ ์œ„ํ•œ Suspense ์‚ฌ์šฉ๋ฟ๋งŒ ์•„๋‹ˆ๋ผ, ์˜ค๋ž˜๋œ ํŒจํ„ด์œผ๋กœ ๋” ๋„๋ฆฌ ์‚ฌ์šฉ๋˜๋Š” React.lazy ์‚ฌ์šฉ์—๋„ ์˜ํ–ฅ์„ ๋ฏธ์นฉ๋‹ˆ๋‹ค. + + + +[@bentonnnnnn](https://x.com/bentonnnnnn/status/1800940807618171270) : ์˜ˆ์ƒ๋Œ€๋กœ ์ด ๋ณ€๊ฒฝ ์‚ฌํ•ญ์€ ์ง€์—ฐ ๋กœ๋“œ๋œ ์ปดํฌ๋„ŒํŠธ(react.lazy)์—๋„ ์˜ํ–ฅ์„ ๋ฏธ์นฉ๋‹ˆ๋‹ค. +์ด์ œ ๋” ์ด์ƒ ๋ณ‘๋ ฌ๋กœ ๊ฐ€์ ธ์˜ค์ง€ ์•Š๊ธฐ ๋•Œ๋ฌธ์— ๋กœ๋”ฉ ์‹œ๊ฐ„์€ ๋‘ ํŽ˜์น˜์˜ ํ•ฉ์ด ๋˜๋ฉฐ, ์ด๋Š” ํฐ ํ›„ํ‡ด๋กœ ๊ฐ„์ฃผ๋˜์–ด์•ผ ํ•ฉ๋‹ˆ๋‹ค. + +--- + +## ๊ทผ๊ฑฐ์™€ DX ์˜ํ–ฅ + +์ด ๋ณ€๊ฒฝ์˜ ๊ทผ๊ฑฐ๋Š”, ์‹ค์ œ๋กœ ์ค‘๋‹จ๋˜๊ธฐ ์ „์— ๋ชจ๋“  ํ˜•์ œ ์š”์†Œ๋ฅผ ๋ Œ๋”๋งํ•˜๋ ค๊ณ  ์‹œ๋„ํ•˜๋Š” ๊ฒƒ์€ ๋น„์šฉ์ด ๋“ค๋ฉฐ, ๋ณธ์งˆ์ ์œผ๋กœ fallback์„ ํ‘œ์‹œํ•˜๋Š” ๊ฒƒ์„ ์ง€์—ฐ์‹œํ‚จ๋‹ค๋Š” ์ ์ž…๋‹ˆ๋‹ค. ๋˜ํ•œ ์ด ๋ณ€๊ฒฝ์€ React ํŒ€์ด React 18 ์ด์ „์— Suspense๋ฅผ ๋„์ž…ํ•˜๋ฉด์„œ๋ถ€ํ„ฐ ์ถ”์ง„ํ•ด ์˜จ "fetch as you render" ์ ‘๊ทผ ๋ฐฉ์‹๊ณผ ์ผ์น˜ํ•ฉ๋‹ˆ๋‹ค. + +์ด์ƒ์ ์œผ๋กœ๋Š”, ์ปดํฌ๋„ŒํŠธ ๋ Œ๋”๋ง ์‹œ ๋ฐ์ดํ„ฐ ํŽ˜์นญ์„ ์‹œ์ž‘ํ•˜๋Š” ๋Œ€์‹ , ๊ฐ€๋Šฅํ•œ ๋นจ๋ฆฌ ๋ฐ์ดํ„ฐ๋ฅผ ๊ฐ€์ ธ์˜ค๋Š” ๊ฒƒ์ด ์ข‹์Šต๋‹ˆ๋‹ค. + +๋น„๋ก ์„ฑ๋Šฅ ๋ฉด์—์„œ๋Š” ์ตœ์ƒ์˜ ์ ‘๊ทผ ๋ฐฉ์‹์ด์ง€๋งŒ, ์ด๋Š” ์ปดํฌ๋„ŒํŠธ์™€ ๋ฐ์ดํ„ฐ ์š”๊ตฌ ์‚ฌํ•ญ์„ ํ•จ๊ป˜ ๋ฐฐ์น˜ํ•˜๋Š” ๊ฒƒ์„ ์–ด๋ ต๊ฒŒ ๋งŒ๋“ค์–ด ๊ฐœ๋ฐœ์ž ๊ฒฝํ—˜(DX)์— ํฐ ๋‹จ์ ์„ ์•ˆ๊ฒจ์ค๋‹ˆ๋‹ค. + +์ด ์ฃผ์ œ์— ๋Œ€ํ•ด ์ด๋ฏธ ๋งŽ์€ ๋…ผ์˜๊ฐ€ ์žˆ์—ˆ๊ณ , ์ด ๋ฌธ์ œ๋ฅผ ํ•ด๊ฒฐํ•˜๊ธฐ ์œ„ํ•ด ํŠน๋ณ„ํžˆ ๋งŒ๋“ค์–ด์ง„ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ๋„ ์กด์žฌํ•˜๊ธฐ ๋•Œ๋ฌธ์— ์—ฌ๊ธฐ์„œ ๊นŠ์ด ๋‹ค๋ฃจ์ง€๋Š” ์•Š๊ฒ ์Šต๋‹ˆ๋‹ค. ๋‹ค๋งŒ, ์ด ํŠน์ • ๋ฌธ์ œ์— ๋Œ€ํ•ด ์ด์•ผ๊ธฐํ•˜๋Š” ๋ช‡ ๊ฐ€์ง€ ํŠธ์œ—์„ ๋‚จ๊ธฐ๊ฒ ์Šต๋‹ˆ๋‹ค. + + + +[@teemu_taskula](https://x.com/teemu_taskula/status/1800770818097754509) : Dominik์˜ ๊ณ ํ†ต์ด ๋Š๊ปด์ง€๋„ค์š” ๐Ÿ˜Ÿ ์ด๊ฑด React์˜ ์ฃผ์š” ์„ค๊ณ„ ์›์น™์ธ composition์— ๋ฐ˜ํ•˜๋Š” ๊ฒƒ ์•„๋‹Œ๊ฐ€์š”? ์ œ๊ฐ€ ์ œ๋Œ€๋กœ ์ดํ•ดํ•œ ๊ฒŒ ๋งž๋‹ค๋ฉด, ์ด์ œ ๋ณต์žกํ•œ ์‚ฌ์ „ ํŽ˜์นญ ํŠธ๋ฆญ ์—†์ด๋Š” ๋ฐ์ดํ„ฐ ์š”๊ตฌ๋ฅผ ๊ตฌ์„ฑํ•  ์ˆ˜ ์—†๊ฒŒ ๋˜์—ˆ์Šต๋‹ˆ๋‹ค. ์•„๋‹ˆ๋ฉด ๋ชจ๋“  ๋ฐ์ดํ„ฐ ํŽ˜์นญ์„ ๊ณตํ†ต ๋ถ€๋ชจ๋กœ ์˜ฌ๋ ค์•ผ ํ•˜์ฃ . +๋ฐ์ดํ„ฐ ํŽ˜์นญ์„ ๊ณตํ†ต ๋ถ€๋ชจ๋กœ ์˜ฌ๋ ค์•ผ ํ•œ๋‹ค๋ฉด Suspense๋ฅผ ์‚ฌ์šฉํ•˜๋Š” ์˜๋ฏธ๊ฐ€ ๋ฌด์—‡์ธ๊ฐ€์š”? ์ €๋Š” ๋น„๋™๊ธฐ ์ž‘์—… ์กฐ์ •์„ ๋” ์‰ฝ๊ฒŒ ๋งŒ๋“œ๋Š” ๊ฒƒ์ด Suspense์˜ ๋ชฉ์ ์ด๋ผ๊ณ  ์ƒ๊ฐํ–ˆ์Šต๋‹ˆ๋‹ค. ๋งŒ์•ฝ view์˜ ๋ฃจํŠธ์—์„œ ๋ฐ์ดํ„ฐ ํŽ˜์นญ์„ ์‹œ์ž‘ํ•ด์•ผ ํ•œ๋‹ค๋ฉด, ์ฐจ๋ผ๋ฆฌ Suspense ์—†์ด ๋ฐ์ดํ„ฐ๋ฅผ ์ฟผ๋ฆฌํ•˜๋Š” ๊ฒƒ์ด ๋‚ซ์Šต๋‹ˆ๋‹ค. + +--- + +์—ฌ๊ธฐ์„œ ์ค‘์š”ํ•œ ์ ์€ ์ปดํฌ๋„ŒํŠธ์™€ ๊ทธ ๋ฐ์ดํ„ฐ ์š”๊ตฌ ์‚ฌํ•ญ์˜ ์ตœ์ ์˜ ์„ฑ๋Šฅ ํŠน์„ฑ๊ณผ ๊ณต๋™ ๋ฐฐ์น˜๋ฅผ ๋™์‹œ์— ๋‹ฌ์„ฑํ•˜๋Š” ๊ฒƒ์ด **์ปดํŒŒ์ผ๋Ÿฌ** ์—†์ด ๋ถˆ๊ฐ€๋Šฅํ•˜๋‹ค๋Š” ๊ฒƒ์ž…๋‹ˆ๋‹ค. ์ด๋Š” Relay๊ฐ€ ์ˆ˜ํ–‰ํ•˜๋Š” ์ž‘์—…์ž…๋‹ˆ๋‹ค. + +## ๊ฒฐ๋ก  + +๋‹คํ–‰ํžˆ๋„ ์ด ์ด์•ผ๊ธฐ๋Š” ํ•ดํ”ผ์—”๋”ฉ์œผ๋กœ ๋๋‚ฌ์Šต๋‹ˆ๋‹ค. ๋งŽ์€ ๊ณต๊ฐœ ๋ฐ˜๋ฐœ, ์—ด๋ค ํ† ๋ก , ๊ทธ๋ฆฌ๊ณ  ์•„๋งˆ๋„ ๋ฐฐํ›„์—์„œ์˜ ์ƒ๋‹นํ•œ ๋…ผ์˜ ๋์—, React ํŒ€์€ ์ด ๋ณ€๊ฒฝ ์‚ฌํ•ญ์„ ๋ณด๋ฅ˜ํ•˜๊ธฐ๋กœ ๊ฒฐ์ •ํ–ˆ์Šต๋‹ˆ๋‹ค. + + + +[@sophiebits](https://x.com/sophiebits/status/1801663976973209620) : ์ข‹์€ ์†Œ์‹์ž…๋‹ˆ๋‹ค. Suspense์™€ ๊ด€๋ จ๋œ ๋ฌธ์ œ์— ๋Œ€ํ•ด +@rickhanlonii, @en_JS, @acdlite์™€ ๋งŒ๋‚ฌ์Šต๋‹ˆ๋‹ค. + +์šฐ๋ฆฌ๋Š” ๋‹จ์ผ ํŽ˜์ด์ง€ ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜(SPA)์— ๋Œ€ํ•ด ๋งŽ์€ ๊ด€์‹ฌ์„ ๊ฐ€์ง€๊ณ  ์žˆ์œผ๋ฉฐ, ํŒ€์ด ์˜ค๋Š˜๋‚  ๋งŽ์€ ์‚ฌ๋žŒ๋“ค์ด ์ด ๊ธฐ๋Šฅ์— ์˜์กดํ•˜๊ณ  ์žˆ๋‹ค๋Š” ๊ฒƒ์„ ์ž˜๋ชป ํŒ๋‹จํ–ˆ์Šต๋‹ˆ๋‹ค. +์—ฌ์ „ํžˆ ํ”„๋ฆฌ๋กœ๋”ฉ์„ ๊ถŒ์žฅํ•˜์ง€๋งŒ, ํ•ญ์ƒ ์‹ค์šฉ์ ์ด์ง€ ์•Š๋‹ค๋Š” ๊ฒƒ์„ ์ธ์‹ํ•˜๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค. +์ข‹์€ ํ•ด๊ฒฐ์ฑ…์„ ์ฐพ์„ ๋•Œ๊นŒ์ง€ React 19.0 ๋ฆด๋ฆฌ์Šค๋ฅผ ๋ณด๋ฅ˜ํ•  ๊ณ„ํš์ž…๋‹ˆ๋‹ค. +์ถ”๊ฐ€ ์†Œ์‹์ด ์žˆ์„ ์˜ˆ์ •์ž…๋‹ˆ๋‹ค. + +--- + +์ด๊ฒƒ์€ ์ปค๋ฎค๋‹ˆํ‹ฐ๊ฐ€ Meta์™€ Vercel ์™ธ๋ถ€์—์„œ React๊ฐ€ ์–ด๋–ป๊ฒŒ ์‚ฌ์šฉ๋˜๋Š”์ง€์— ๋Œ€ํ•œ ๊ณ ๋ ค ์—†์ด ๋„์ž…๋œ ๋ณ€๊ฒฝ ์‚ฌํ•ญ์— ๋ฐ˜๋ฐœํ•œ ์ฒซ ๋ฒˆ์งธ ์‚ฌ๋ก€๊ฐ€ ์•„๋‹™๋‹ˆ๋‹ค. React ํŒ€๊ณผ ํŠนํžˆ Vercel์ด RSCs๋ฅผ React๋กœ ๊ตฌ์ถ•ํ•˜๋Š” ๊ธฐ๋ณธ ์š”์†Œ๋กœ ๋งŒ๋“ค๋ ค๋Š” ์ถ”์ง„์ด ๊ทธ ํ•œ ์‚ฌ๋ก€์ž…๋‹ˆ๋‹ค. + +React์˜ ์œ ์ง€ ๊ด€๋ฆฌ์ž๋“ค์ด React์˜ ๋ฏธ๋ž˜๋ฅผ ์œ„ํ•ด ์ตœ์„ ์ด๋ผ๊ณ  ์ƒ๊ฐํ•˜๋Š” ๊ฒƒ๊ณผ ์ปค๋ฎค๋‹ˆํ‹ฐ์˜ ์˜๊ฒฌ ์‚ฌ์ด์— ๋ถˆ์ผ์น˜๊ฐ€ ๋ช…ํ™•ํžˆ ์กด์žฌํ•ฉ๋‹ˆ๋‹ค. ์ด๋Ÿฌํ•œ ์ปค๋ฎค๋‹ˆ์ผ€์ด์…˜ ๋ฌธ์ œ๋“ค์ด ๋” ์‹ฌํ™”๋ ์ง€๋Š” ์•„์ง ์ง€์ผœ๋ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.