๐Ÿคฌ-React Strict Mode

๊น€๋™๊ทœยท2022๋…„ 10์›” 27์ผ
0

React๊ฐœ๋ฐœ์ผ์ง€

๋ชฉ๋ก ๋ณด๊ธฐ
1/5
post-custom-banner

๐Ÿ˜ž-๊ฒฝํ—˜

๋ฆฌ์•กํŠธ๋กœ ํ”„๋กœ์ ํŠธ๋ฅผ ์ง„ํ–‰ํ•˜๋Š” ์ค‘ useEffect ๋ฅผ ์‚ฌ์šฉํ•˜๋Š”๋ฐ 2๋ฒˆ์”ฉ ํ•จ์ˆ˜๋ฅผ ํ˜ธ์ถœํ•˜๋Š” ๊ฒฝ์šฐ๊ฐ€ ๋ฐœ์ƒํ•ด ๋ฌธ์ œ์ ์„ ์ฐพ์•„๋ดค๋”๋‹ˆ React index.js์—์„œ strictMode ๊ฐ€ ์กด์žฌํ•œ๋‹ค๋ฉด ๋žœ๋”๋ง์„ 2๋ฒˆ์”ฉ ํ•˜๊ฒŒ ํ•˜์—ฌ ๊ฐœ๋ฐœ ๋ชจ๋“œ์—์„œ๋Š” ์˜ค๋ฅ˜๋ฅผ ์ž˜์žก๊ธฐ์œ„ํ•ด ๊ทธ๋Ÿฐ ํ˜„์ƒ์ด ์ผ์–ด๋‚œ๋‹ค๊ณ  ํ•œ๋‹ค.
์ดํ˜„์ƒ ๋•Œ๋ฌธ์— ๋ช‡๋ฒˆ์„ ์ฝ”๋“œ๋ฅผ ์ˆ˜์ •ํ–ˆ๋Š”์ง€.. ํ•˜...

์ง€ํ”ผ์ง€๊ธฐ๋ฉด ๋ฐฑ์ „๋ฐฑ์Šน React Strict Mode ๋ฅผ ์•Œ๊ณ ๋„˜์–ด๊ฐ€์ž

๋ฆฌ์•กํŠธ ๊ณต์‹๋ฌธ์„œ์—์„œ์˜ ์„ค๋ช…์ด๋‹ค.

StrictMode๋Š” ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜ ๋‚ด์˜ ์ž ์žฌ์ ์ธ ๋ฌธ์ œ๋ฅผ ์•Œ์•„๋‚ด๊ธฐ ์œ„ํ•œ ๋„๊ตฌ์ž…๋‹ˆ๋‹ค. Fragment์™€ ๊ฐ™์ด UI๋ฅผ ๋ Œ๋”๋งํ•˜์ง€ ์•Š์œผ๋ฉฐ, ์ž์†๋“ค์— ๋Œ€ํ•œ ๋ถ€๊ฐ€์ ์ธ ๊ฒ€์‚ฌ์™€ ๊ฒฝ๊ณ ๋ฅผ ํ™œ์„ฑํ™”ํ•ฉ๋‹ˆ๋‹ค.

์ž ์žฌ์ ์ธ ๋ฌธ์ œ? ๋„ˆ๋ฌด ์ถ”์ƒ์ ์ธ ๊ฐœ๋…์ด๋‹ค ์กฐ๊ธˆ๋” ๊นŠ๊ฒŒ ์•Œ์•„๋ณด์ž

StrictMode๋Š” ์•„๋ž˜์™€ ๊ฐ™์€ ๋ถ€๋ถ„์—์„œ ๋„์›€์ด ๋ฉ๋‹ˆ๋‹ค.

  • ์•ˆ์ „ํ•˜์ง€ ์•Š์€ ์ƒ๋ช…์ฃผ๊ธฐ๋ฅผ ์‚ฌ์šฉํ•˜๋Š” ์ปดํฌ๋„ŒํŠธ ๋ฐœ๊ฒฌ
  • ๋ ˆ๊ฑฐ์‹œ ๋ฌธ์ž์—ด ref ์‚ฌ์šฉ์— ๋Œ€ํ•œ ๊ฒฝ๊ณ 
  • ๊ถŒ์žฅ๋˜์ง€ ์•Š๋Š” findDOMNode ์‚ฌ์šฉ์— ๋Œ€ํ•œ ๊ฒฝ๊ณ 
  • ์˜ˆ์ƒ์น˜ ๋ชปํ•œ ๋ถ€์ž‘์šฉ ๊ฒ€์‚ฌ
  • ๋ ˆ๊ฑฐ์‹œ context API ๊ฒ€์‚ฌ
  • Ensuring reusable state

๐Ÿง ์ดํ•ด ๊ฐ€๊ธฐ ์–ด๋ ค์šด ๋ถ€๋ถ„์— ๊ด€ํ•œ ๋งํฌ

์ƒ๋ช…์ฃผ๊ธฐ ๋ฉ”์„œ๋“œ
Ref์™€Dom

post-custom-banner

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