๋ฆฌ์•กํŠธ 3

[React] ๊ฐ€์ƒ๋”

๐Ÿ“Œ๊ฐ€์ƒ๋”์˜ ๊ฐœ๋… - ๊ณต์‹๋ฌธ์„œ ์ •์˜ The virtual DOM (VDOM) is a programming concept where an ideal, or “virtual”, representation of a UI is kept in memory and synced with the “real” DOM by a library such as ReactDOM. This process is called reconciliation. ๊ฐ€์ƒ์œผ๋กœ UI๋ฅผ ๋ฒ„์ธ„์–ผ๋”์— ์ €์žฅํ•ด๋‘์—ˆ๋‹ค๊ณ  Real Dom๊ณผ ์—ฐ๋™(sync) ์‹œ์ผœ์ฃผ๋Š” ํ”„๋กœ๊ทธ๋ž˜๋ฐ ์ปจ์…‰ ์ผ๋ช… reconciliation(ํ™”ํ•ด) ๊ณผ์ •์ด๋ผ ์ •์˜ ๐Ÿ“ŒDiffing ์•Œ๊ณ ๋ฆฌ์ฆ˜ - ๋ฆฌ์•กํŠธ๋Š” Real Dom๊ณผ Virtual Dom์„ ์ฐธ๊ณ ํ•˜๋ฉด์„œ diffing ์•Œ๊ณ ๋ฆฌ์ฆ˜์„ ์ด์šฉํ•ด ๋ณ€ํ™”๊ฐ€ ์ผ..

[React] ํ•จ์ˆ˜ํ˜•๊ณผ ํด๋ž˜์Šคํ˜•์˜ ์žฅ๋‹จ์  ๋น„๊ต

ํ•จ์ˆ˜ํ˜• ์ปดํฌ๋„ŒํŠธ ํด๋ž˜์Šคํ˜• ์ปดํฌ๋„ŒํŠธ ์„ ์–ธ๋ฐฉ์‹ 1. state, lifeCycle ๊ด€๋ จ ๊ธฐ๋Šฅ ์‚ฌ์šฉ ๋ถˆ๊ฐ€(v16.8๋ถ€ํ„ฐ Hook์œผ๋กœ ํ•ด๊ฒฐ) 2. ํด๋ž˜์Šคํ˜•๋ณด๋‹ค ๋ฉ”๋ชจ๋ฆฌ ์ž์›์„ ๋œ ์‚ฌ์šฉ 3. ์ปดํฌ๋„ŒํŠธ ์„ ์–ธ์ด ํŽธํ•จ 1. class ํ‚ค์›Œ๋“œ ํ•„์š” 2. render() ๋ฉ”์†Œ๋“œ ๋ฐ˜๋“œ์‹œ ํ•„์š” 3. Component๋กœ ์ƒ์†์„ ๋ฐ›์•ผํ•จ 4. state, lifeCycle ๊ด€๋ จ ๊ธฐ๋Šฅ ์‚ฌ์šฉ ๊ฐ€๋Šฅ state 1. useState ํ•จ์ˆ˜๋กœ state๋ฅผ ์‚ฌ์šฉ 2. useState ํ•จ์ˆ˜๋ฅผ ํ˜ธ์ถœํ•˜๋ฉด ๋ฐฐ์—ด์ด ๋ฐ˜ํ™˜๋˜๋Š”๋ฐ ์ฒซ๋ฒˆ์งธ ์›์†Œ๋Š” ํ˜„์žฌ ์ƒํƒœ, ๋‘๋ฒˆ์งธ ์›์†Œ๋Š” ์ƒํƒœ๋ฅผ ๋ฐ”๊ฟ”์ฃผ๋Š” ํ•จ์ˆ˜ 1. constructor ์•ˆ์—์„œ this.state ์ดˆ๊ธฐ ๊ฐ’ ์„ค์ • ๊ฐ€๋Šฅ 2. this.setState()๋ฅผ ํ†ตํ•ด state๊ฐ’์„ ๋ณ€๊ฒฝ props 1. props๋ฅผ ๋ถˆ๋Ÿฌ์˜ฌ..

[์†Œ๊ฐœํŒ…์„œ๋น„์Šค] ๋ฐฉ ์ž…์žฅ ์ฝ”๋“œ ๋ถ€์—ฌํ•˜๋Š” ์˜ค๋ฅ˜ ํ•ด๊ฒฐ

๐Ÿ“Œ ์ƒํ™ฉ์ •๋ฆฌ 1. ์—ญํ•  ์„ ํƒ ํ™”๋ฉด์—์„œ ์‚ฌ์šฉ์ž๊ฐ€ ์—ญํ• ์„ ์„ ํƒํ•œ๋‹ค 2. ์„ ํƒํ•œ ์—ญํ•  ์ •๋ณด๋ฅผ ์„œ๋ฒ„๋กœ ๋ณด๋‚ด๋ฉด, ์„œ๋ฒ„๊ฐ€ ๋žœ๋ค ๋งค์นญ ๊ณต์‹์— ๋งž์ถฐ์„œ ๋งค์นญ ์ •๋ณด๋ฅผ ๋ฐ˜ํ™˜ํ•œ๋‹ค 3. ๋งค์นญ ์ •๋ณด๋ฅผ ์ด์šฉํ•ด ๋ฏธํŒ… ์„œ๋น„์Šค์— ์ž…์žฅํ•œ๋‹ค ๐Ÿ“Œ ํ•ด๊ฒฐ๊ณผ์ • 1. ๋งค์นญ ๋Œ€๊ธฐ์‹ค๋กœ ์ด๋™ํ•˜๋Š” ํ•จ์ˆ˜๋ฅผ ์ •์˜ 1-1. ๋งค์นญ ๋Œ€๊ธฐ์‹ค๋กœ ์ด๋™ํ•˜๋Š” ํ•จ์ˆ˜๋ฅผ ์†Œ๊ฐœํŒ… ์‹œ์ž‘ํ•˜๊ธฐ ๋ฒ„ํŠผ์— ๊ฑธ์–ด์คŒ 1-2. ์ฐธ๊ณ ๋กœ ์—ญํ•  ์ฝ”๋“œ๋ฅผ ์ค‘์•™๊ด€๋ฆฌ์†Œ์— ์ €์žฅํ•˜๋Š” ๋ฐฉ์‹์€ ์•„๋ž˜์™€ ๊ฐ™์ด ์ •์˜๋˜์–ด ์žˆ์Œ 2. ๋งค์นญ ๋Œ€๊ธฐ์‹ค์— ์ž…์žฅํ•˜๋ฉด ๋ฐ”๋กœ ๋งค์นญ ์ •๋ณด ๋ฐ›์•„์˜ค๋Š” matchStart ํ•จ์ˆ˜ ์‹คํ–‰ 2-1. classํ˜• ํ•จ์ˆ˜์—์„œ ์ค‘์•™๊ด€๋ฆฌ์†Œ์— ์žˆ๋Š” state๋ฅผ ์‚ฌ์šฉํ•˜๋Š” ๋ฐฉ๋ฒ•, ์Šฌ๋ผ์ด์Šค์˜ ์•ก์…˜ํ•จ์ˆ˜๋ฅผ ์‚ฌ์šฉํ•˜๋Š” ๋ฐฉ๋ฒ•์€ ๊ตฌ๊ธ€๋ง์„ ํ†ตํ•ด ์ฐพ์•˜์Œ 3. matchStartํ•จ์ˆ˜๋Š” ์•„๋ž˜์™€ ๊ฐ™์ด ๋™์ž‘ํ•จ 3-1. history๋ฅผ ์‚ฌ์šฉ..