From 40b7e78424e4b050ff3f4adb0268fab8ff3164da Mon Sep 17 00:00:00 2001 From: RyuDongHo Date: Thu, 14 Nov 2024 01:30:10 +0900 Subject: [PATCH] =?UTF-8?q?keyword:=205~6=EC=A3=BC=EC=B0=A8=20=ED=82=A4?= =?UTF-8?q?=EC=9B=8C=EB=93=9C=20=EC=B6=94=EA=B0=80=2005=2006=20chapter=20?= =?UTF-8?q?=ED=82=A4=EC=9B=8C=EB=93=9C=20=EC=B6=94=EA=B0=80=20=ED=96=88?= =?UTF-8?q?=EC=8A=B5=EB=8B=88=EB=8B=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- keyword/chapter05/keyword.md | 615 +++++++++++++++++++++++++++++++++++ keyword/chapter06/keyword.md | 337 +++++++++++++++++++ 2 files changed, 952 insertions(+) create mode 100644 keyword/chapter05/keyword.md create mode 100644 keyword/chapter06/keyword.md diff --git a/keyword/chapter05/keyword.md b/keyword/chapter05/keyword.md new file mode 100644 index 0000000..8a0e0e3 --- /dev/null +++ b/keyword/chapter05/keyword.md @@ -0,0 +1,615 @@ +# ๐Ÿ“ย ํ•™์Šต ๋ชฉํ‘œ + +--- + +1. **`์œ ํšจ์„ฑ ๊ฒ€์‚ฌ`**์— ๋Œ€ํ•ด ํ•™์Šตํ•ฉ๋‹ˆ๋‹ค. +2. **`input ํƒœ๊ทธ`**์˜ ์—ฌ๋Ÿฌ๊ฐ€์ง€ ์†์„ฑ์— ๋Œ€ํ•ด ํ•™์Šตํ•ฉ๋‹ˆ๋‹ค. +3. **`Custom Hook`**์„ ๋งŒ๋“ค์—ˆ์„ ๋–„์˜ ์žฅ์ ์— ๋Œ€ํ•ด ์•Œ์•„๋ด…๋‹ˆ๋‹ค. +4. **`Custom Hook`**์„ ํ™œ์šฉํ•˜์—ฌ, ํšจ์œจ์ ์œผ๋กœ, ์œ ํšจ์„ฑ ๊ฒ€์‚ฌ๋ฅผ ํ•˜๋ฉฐ, ํผ ๋ฐ์ดํ„ฐ๋ฅผ ๊ด€๋ฆฌํ•˜๋Š” ๋ฐฉ๋ฒ•์— ๋Œ€ํ•ด ์•Œ์•„๋ด…๋‹ˆ๋‹ค. + +# โš ๏ธย ย ์Šคํ„ฐ๋”” ์ง„ํ–‰ ๋ฐฉ๋ฒ• + +--- + +1. ์Šคํ„ฐ๋””๋ฅผ ์ง„ํ–‰ํ•˜๊ธฐ ์ „, ์›Œํฌ๋ถ ๋‚ด์šฉ๋“ค์„ ๋ชจ๋‘ ์ฑ„์šฐ๊ณ  ์Šคํ„ฐ๋””์—์„œ ์„œ๋กœ ๋ชจ๋ฅด๋Š” ๋‚ด์šฉ๋“ค์„ ์Šคํ„ฐ๋””์›๊ณผ ํ•จ๊ป˜ ๊ณต์œ ํ•ด ์ฃผ์„ธ์š”. +2. ์‹ค์Šต๊ณผ ๋ฏธ์…˜์€ ์›Œํฌ๋ถ ๋‚ด์šฉ๋“ค์„ ๋ชจ๋‘ ์™„๋ฃŒํ•œ ํ›„, ์Šคํ„ฐ๋”” ์ „์— ์ง„ํ–‰ํ•ด ์˜ค์„ธ์š”! + - 1์ฃผ ์ฐจ ์Šคํ„ฐ๋”” ์ด์ „์— 1์ฃผ ์ฐจ ์›Œํฌ๋ถ์„ ์™„์„ฑํ•œ ํ›„ ์Šคํ„ฐ๋””๋ฅผ ์ง„ํ–‰ํ•ด ์ฃผ์„ธ์š”. +3. ์Šคํ„ฐ๋”” ์‹œ๊ฐ„์—๋Š” ๊ฐ์ž ํ•ด ์˜จ ๋ฏธ์…˜๋“ค์„ ๊ณต์œ ํ•˜๊ณ , ์•„๋ž˜์˜ ๊ณผ์ •์„ ์ง„ํ–‰ํ•ฉ๋‹ˆ๋‹ค. + 1. ์Šคํ„ฐ๋””์›๊ณผ ํ•จ๊ป˜ ์ฝ”๋“œ ๋ฆฌ๋ทฐ ์ง„ํ–‰. + 2. ์ฝ”๋“œ ๋ฆฌ๋ทฐ ์ดํ›„, ๋ณธ์ธ์˜ ์ฝ”๋“œ์˜ ๋ฌธ์ œ๊ฐ€ ์žˆ๋Š” ๊ฒฝ์šฐ ๋ฆฌํŒฉํ† ๋ง ์ง„ํ–‰. + 3. ํŒ€์›๋“ค๊ณผ, ์กฐ๊ธˆ ๋” ์ฝ”๋“œ๋ฅผ ๊น”๋”ํ•˜๊ฒŒ ์ž‘์„ฑํ•  ์ˆ˜ ์žˆ๋Š” ๊ฐœ์„ ์ ์ด ์žˆ์„์ง€ ๊ณ ๋ฏผ ํ›„, ๋ฆฌํŒฉํ† ๋ง ์ง„ํ–‰. + 4. ๊ฐ์ž ๋ฏธ์…˜์„ ์ง„ํ–‰ํ•˜๋ฉด์„œ ํ•ด๊ฒฐํ•˜์ง€ ๋ชปํ•œ ์ด์Šˆ๋ฅผ ๊ณต์œ  ํ›„, ํ•ด๋‹น ์ด์Šˆ๋ฅผ ๋„์›€๋ฐ›์•„ ํ•ด๊ฒฐ. +4. ๋งค์ฃผ ์ฃผ์–ด์ง„ ๋ฏธ์…˜์„ ์„ฑ์‹คํ•˜๊ฒŒ ์ œ์ถœํ•ฉ๋‹ˆ๋‹ค. +5. ๐Ÿ ย ์ด๋ชจ์ง€๊ฐ€ ๋ถ™์–ด์žˆ๋Š” ๊ณณ์€, ์ง์ ‘ ์—ฌ๋Ÿฌ๋ถ„๋“ค์ด ์ฑ„์›Œ ๋„ฃ์œผ์…”์•ผ ํ•˜๋Š” ๋ถ€๋ถ„์ž…๋‹ˆ๋‹ค. ๊ผญ Google์„ ํ†ตํ•œ ๊ฒ€์ƒ‰์„ ํ•˜์‹œ๊ณ , VSCode๋ฅผ ํ™œ์šฉํ•˜์—ฌ, ์‹คํ–‰ ๊ฒฐ๊ณผ๋ฅผ ๋ˆˆ์œผ๋กœ ๋ณด์‹œ๋ฉด์„œ ์ •๋ฆฌํ•ด ์ฃผ์„ธ์š”! + +# ๐Ÿ“ธย ์ž ๊น ! ์Šคํ„ฐ๋”” ์ธ์ฆ์ƒท์€ ์ฐ์œผ์…จ๋‚˜์š”?๐Ÿ“ธ + +--- + +* ์Šคํ„ฐ๋””๋ฆฌ๋”๊ป˜์„œ ๋Œ€ํ‘œ๋กœ ๋งค ์ฃผ์ฐจ๋งˆ๋‹ค ํ•œ ์žฅ ๋‚จ๊ฒจ์ฃผ์‹œ๋ฉด ์ข‹๊ฒ ์Šต๋‹ˆ๋‹ค!๐Ÿ™†๐Ÿ’— + (์‚ฌ์ง„์„ ์ €์žฅํ•ด์„œ ์ด๋ฏธ์ง€ ์ž„๋ฒ ๋“œ๋ฅผ ํ•˜์…”๋„ ์ข‹๊ณ , ๋ณต์‚ฌ+๋ถ™์—ฌ๋„ฃ๊ธฐํ•ด์„œ ๋„ฃ์–ด์ฃผ์…”๋„ ์ข‹์Šต๋‹ˆ๋‹ค!) + +[]() + +# ๐ŸŽฏย ํ•ต์‹ฌ ํ‚ค์›Œ๋“œ + +--- + + + +### ํ‚ค์›Œ๋“œ ์ •๋ฆฌ ๐Ÿ  + +- useRef ๐Ÿ  + + ๋ Œ๋”๋ง์ด ๋˜์–ด๋„, ์œ ์ง€ํ•˜๊ณ  ์‹ถ์€ ๊ฐ’์ด ์žˆ์„ ๋•Œ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค. + + useRef๋กœ ๊ฐ’์„ ์ €์žฅํ•ฉ๋‹ˆ๋‹ค. + +- input์˜ ์ฃผ์š” ํ”„๋กœํผํ‹ฐ ๐Ÿ  + - ์•„๋ž˜ ๋‚ด์šฉ ์ด์™ธ์—, ์ž์ฃผ ์‚ฌ์šฉํ•˜๋Š” ํ”„๋กœํผํ‹ฐ๊ฐ€ ์žˆ์œผ๋ฉด ์ถ”๊ฐ€๋กœ ๋” ์ •๋ฆฌํ•ด์ฃผ์„ธ์š”! ๐Ÿ  + + email ํƒ€์ž…์„ ์“ฐ๋ฉด, ๊ฐ„๋‹จํ•˜๊ฒŒ ์ด๋ฉ”์ผ ํ˜•์‹์„ ์ž…๋ ฅํ•˜๋„๋ก ํ•˜๋Š” ์ž…๋ ฅ ์ฐฝ์„ ๋งŒ๋“ค ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. + + + ### 1. `type` + + - **์„ค๋ช…**: ์ž…๋ ฅ ํ•„๋“œ์˜ ์ข…๋ฅ˜๋ฅผ ์„ค์ •ํ•ฉ๋‹ˆ๋‹ค. + - **๊ฐ’ ์˜ˆ์‹œ**: `"text"`, `"password"`, `"email"`, `"number"`, `"checkbox"`, `"radio"` ๋“ฑ + - **์˜ˆ์‹œ**: `` + + ### 2. `value` + + - **์„ค๋ช…**: ์ž…๋ ฅ ํ•„๋“œ์˜ ๊ฐ’์„ ์„ค์ •ํ•˜๊ณ  ์ œ์–ดํ•  ๋•Œ ์‚ฌ์šฉ๋ฉ๋‹ˆ๋‹ค. **Controlled Component**์—์„œ ์ž์ฃผ ์‚ฌ์šฉ๋ฉ๋‹ˆ๋‹ค. + - **๊ฐ’ ์˜ˆ์‹œ**: ๋ฌธ์ž์—ด ๋˜๋Š” ์ˆซ์ž + - **์˜ˆ์‹œ**: `` + + ### 3. `defaultValue` + + - **์„ค๋ช…**: ์ดˆ๊ธฐ๊ฐ’์„ ์„ค์ •ํ•˜๋Š” ๋ฐ ์‚ฌ์šฉ๋ฉ๋‹ˆ๋‹ค. + - **๊ฐ’ ์˜ˆ์‹œ**: ๋ฌธ์ž์—ด ๋˜๋Š” ์ˆซ์ž + - **์˜ˆ์‹œ**: `` + + ### 4. `onChange` + + - **์„ค๋ช…**: ์‚ฌ์šฉ์ž๊ฐ€ ์ž…๋ ฅ ํ•„๋“œ์— ๊ฐ’์„ ์ž…๋ ฅํ•˜๊ฑฐ๋‚˜ ๋ณ€๊ฒฝํ•  ๋•Œ ํ˜ธ์ถœ๋˜๋Š” ์ด๋ฒคํŠธ ํ•ธ๋“ค๋Ÿฌ์ž…๋‹ˆ๋‹ค. + - **๊ฐ’ ์˜ˆ์‹œ**: ํ•จ์ˆ˜ + - **์˜ˆ์‹œ**: ` setValue(e.target.value)} />` + + ### 5. `placeholder` + + - **์„ค๋ช…**: ์ž…๋ ฅ ํ•„๋“œ๊ฐ€ ๋น„์–ด ์žˆ์„ ๋•Œ ํ‘œ์‹œ๋˜๋Š” ํžŒํŠธ ํ…์ŠคํŠธ์ž…๋‹ˆ๋‹ค. + - **๊ฐ’ ์˜ˆ์‹œ**: ๋ฌธ์ž์—ด + - **์˜ˆ์‹œ**: `` + + ### 6. `checked` + + - **์„ค๋ช…**: ์ฒดํฌ๋ฐ•์Šค๋‚˜ ๋ผ๋””์˜ค ๋ฒ„ํŠผ์ด ์„ ํƒ๋˜์—ˆ๋Š”์ง€ ์—ฌ๋ถ€๋ฅผ ์ œ์–ดํ•ฉ๋‹ˆ๋‹ค. + - **๊ฐ’ ์˜ˆ์‹œ**: `true` ๋˜๋Š” `false` + - **์˜ˆ์‹œ**: `` + + ### 7. `defaultChecked` + + - **์„ค๋ช…**: ์ฒดํฌ๋ฐ•์Šค๋‚˜ ๋ผ๋””์˜ค ๋ฒ„ํŠผ์˜ ์ดˆ๊ธฐ ์ƒํƒœ๋ฅผ ์„ค์ •ํ•ฉ๋‹ˆ๋‹ค. + - **๊ฐ’ ์˜ˆ์‹œ**: `true` ๋˜๋Š” `false` + - **์˜ˆ์‹œ**: `` + + ### 8. `disabled` + + - **์„ค๋ช…**: ์ž…๋ ฅ ํ•„๋“œ๋ฅผ ๋น„ํ™œ์„ฑํ™”ํ•˜์—ฌ ์‚ฌ์šฉ์ž ์ž…๋ ฅ์„ ๋ง‰์Šต๋‹ˆ๋‹ค. + - **๊ฐ’ ์˜ˆ์‹œ**: `true` ๋˜๋Š” `false` + - **์˜ˆ์‹œ**: `` + + ### 9. `readOnly` + + - **์„ค๋ช…**: ์ž…๋ ฅ ํ•„๋“œ์˜ ๊ฐ’์„ ์ฝ๊ธฐ ์ „์šฉ์œผ๋กœ ์„ค์ •ํ•ฉ๋‹ˆ๋‹ค. ์‚ฌ์šฉ์ž๋Š” ๊ฐ’์„ ๋ณ€๊ฒฝํ•  ์ˆ˜ ์—†์Šต๋‹ˆ๋‹ค. + - **๊ฐ’ ์˜ˆ์‹œ**: `true` ๋˜๋Š” `false` + - **์˜ˆ์‹œ**: `` + + ### 10. `name` + + - **์„ค๋ช…**: ํผ ๋ฐ์ดํ„ฐ๋ฅผ ์ œ์ถœํ•  ๋•Œ ์„œ๋ฒ„๋กœ ์ „์†ก๋˜๋Š” ๋ฐ์ดํ„ฐ์˜ ์ด๋ฆ„์„ ์ง€์ •ํ•ฉ๋‹ˆ๋‹ค. + - **๊ฐ’ ์˜ˆ์‹œ**: ๋ฌธ์ž์—ด + - **์˜ˆ์‹œ**: `` + + ### 11. `maxLength` + + - **์„ค๋ช…**: ์ž…๋ ฅํ•  ์ˆ˜ ์žˆ๋Š” ์ตœ๋Œ€ ๊ธ€์ž ์ˆ˜๋ฅผ ์ง€์ •ํ•ฉ๋‹ˆ๋‹ค. + - **๊ฐ’ ์˜ˆ์‹œ**: ์ˆซ์ž + - **์˜ˆ์‹œ**: `` + + ### 12. `min` / `max` + + - **์„ค๋ช…**: ์ˆซ์ž ๋˜๋Š” ๋‚ ์งœ ์ž…๋ ฅ์—์„œ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋Š” ์ตœ์†Œ/์ตœ๋Œ€ ๊ฐ’์„ ์ง€์ •ํ•ฉ๋‹ˆ๋‹ค. + - **๊ฐ’ ์˜ˆ์‹œ**: ์ˆซ์ž ๋˜๋Š” ๋‚ ์งœ + - **์˜ˆ์‹œ**: `` + + ### 13. `autoFocus` + + - **์„ค๋ช…**: ํŽ˜์ด์ง€๊ฐ€ ๋กœ๋“œ๋  ๋•Œ ์ž๋™์œผ๋กœ ์ž…๋ ฅ ํ•„๋“œ์— ํฌ์ปค์Šค๋ฅผ ์ค๋‹ˆ๋‹ค. + - **๊ฐ’ ์˜ˆ์‹œ**: `true` ๋˜๋Š” `false` + - **์˜ˆ์‹œ**: `` + + ### 14. `required` + + - **์„ค๋ช…**: ์ž…๋ ฅ ํ•„๋“œ๋ฅผ ํ•„์ˆ˜ ์ž…๋ ฅ์œผ๋กœ ์„ค์ •ํ•ฉ๋‹ˆ๋‹ค. ํผ์„ ์ œ์ถœํ•  ๋•Œ ์ด ํ•„๋“œ๊ฐ€ ๋น„์–ด ์žˆ์œผ๋ฉด ์ œ์ถœ์ด ๊ฑฐ๋ถ€๋ฉ๋‹ˆ๋‹ค. + - **๊ฐ’ ์˜ˆ์‹œ**: `true` ๋˜๋Š” `false` + - **์˜ˆ์‹œ**: `` + +### **`Controlled Input`** vs **`UnControlled Input`** + +- Controlled Input + + ### Controlled Input + + **`Controlled Input`**์€ React์˜ ์ƒํƒœ(state)์— ์˜ํ•ด ํผ์˜ ๊ฐ’์„ ๊ด€๋ฆฌํ•˜๋Š” ๋ฐฉ์‹์ž…๋‹ˆ๋‹ค. Input์˜ value๊ฐ€ ์ปดํฌ๋„ŒํŠธ์˜ ์ƒํƒœ์— ์—ฐ๊ฒฐ๋˜์–ด ์žˆ๊ณ , ์ƒํƒœ๊ฐ’์ด ๋‹ฌ๋ผ์งˆ ๋–„ ๋งˆ๋‹ค, ์ž…๋ ฅ ํ•„๋“œ์˜ ๊ฐ’๋„ ๊ฐฑ์‹ ๋ฉ๋‹ˆ๋‹ค. + + ์‰ฝ๊ฒŒ ๋งํ•ด์„œ, Input์˜ ๊ฐ’์€, **`React Component๊ฐ€ ์ œ์–ด`**ํ•˜๊ณ , ๋ชจ๋“  ์ž…๋ ฅ ๋ณ€ํ™” ๋˜ํ•œ, **`์ปดํฌ๋„ŒํŠธ์˜ ์ƒํƒœ๋กœ ๋ฐ˜์˜`**๋˜์–ด์ง‘๋‹ˆ๋‹ค. + + ํŠน์ง• + + - Input์˜ value๋Š”, React์˜ **`state`**๋กœ ๊ด€๋ฆฌ๋ฉ๋‹ˆ๋‹ค. + - ์ƒํƒœ ๊ฐ’์ด, **`Input์˜ value ์†์„ฑ์— ์ง์ ‘์ ์œผ๋กœ ์—ฐ๊ฒฐ`** ๋จ. + - **`Input`**์˜ **`Value`**๊ฐ€ **`๋ณ€๊ฒฝ`**๋˜๋ฉด, **`์ƒํƒœ๊ฐ€ ์—…๋ฐ์ดํŠธ`**๋˜๊ณ , **`์ƒํƒœ๊ฐ€ ๋‹ค์‹œ ๋ Œ๋”๋ง์„ Trigger`** ํ•จ. + - **`React`**๊ฐ€ **`Form ์š”์†Œ์˜ ํ˜„์žฌ ๊ฐ’์„ ํ•ญ์ƒ ์•Œ๊ณ  ์žˆ๊ธฐ์— ์ œ์–ด๊ฐ€ ์šฉ์ด`**. + + ```tsx + import { useState } from 'react'; + + function ControlledInput() { + const [inputValue, setInputValue] = useState(''); + + const handleChange = (event) => { + setInputValue(event.target.value); + }; + + return ( +
+ +

์ž…๋ ฅ: {inputValue}

+
+ ); + } + + export default ControlledInput; + + ``` + + ### ์žฅ์ : + + - ์ƒํƒœ๋ฅผ ํ†ตํ•ด ๊ฐ’์ด ์ง์ ‘์ ์œผ๋กœ ์ œ์–ด๋˜๊ธฐ ๋•Œ๋ฌธ์— **`ํผ ๋ฐ์ดํ„ฐ๋ฅผ ๊ฒ€์ฆ`**ํ•˜๊ฑฐ๋‚˜ **`์กฐ์ž‘`**ํ•˜๊ธฐ๊ฐ€ ์‰ฝ์Šต๋‹ˆ๋‹ค. + - **`์‚ฌ์šฉ์ž ์ž…๋ ฅ์„ ์‹ค์‹œ๊ฐ„์œผ๋กœ ๊ฒ€์ฆ`**ํ•˜๊ฑฐ๋‚˜ **`ํฌ๋งท์„ ์กฐ์ •`**ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. + + ### ๋‹จ์ : + + - **`์ปดํฌ๋„ŒํŠธ์—์„œ ์ƒํƒœ ๊ด€๋ฆฌ๊ฐ€ ๋ณต์žก`**ํ•ด์งˆ ์ˆ˜ ์žˆ์œผ๋ฉฐ, ํŠนํžˆ ํผ ๋ฐ์ดํ„ฐ์— ๋„ˆ๋ฌด ๋งŽ์€ value๋“ค์„ ๊ด€๋ฆฌํ•˜๋Š” ๊ฒฝ์šฐ **`์„ฑ๋Šฅ์— ๋ถ€๋‹ด`**์ด ๋  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. + +- UnControlled Input + + ### UnControlled Input + + **`Uncontrolled Input`**์€ React์˜ state๊ฐ€ ์•„๋‹Œ DOM ์ž์ฒด์—์„œ ์ž…๋ ฅ ๊ฐ’์„ ๊ด€๋ฆฌํ•˜๋Š” ๋ฐฉ์‹์ž…๋‹ˆ๋‹ค. ํผ์˜ ๊ฐ’์€ **`React ์ปดํฌ๋„ŒํŠธ๊ฐ€ ์ง์ ‘ ๊ด€๋ฆฌํ•˜์ง€ ์•Š๊ณ `**, ํ•„์š”ํ•  ๋•Œ DOM์—์„œ ์ง์ ‘ ๊ฐ’์„ ์ฐธ์กฐํ•˜๋Š” ๋ฐฉ๋ฒ•์ž…๋‹ˆ๋‹ค. ์ด๋ฅผ ์œ„ํ•ด `ref`๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ **`DOM ์š”์†Œ์— ์ง์ ‘ ์ ‘๊ทผ`**ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. + + ### ํŠน์ง• + + - ์ž…๋ ฅ๊ฐ’์ด `state`์— ์˜์กดํ•˜์ง€ ์•Š๊ณ , React์˜ ์ œ์–ด ๋ฐ–์—์„œ ๊ด€๋ฆฌ๋ฉ๋‹ˆ๋‹ค. + - ํผ ์š”์†Œ์˜ ๊ฐ’์€ ์‚ฌ์šฉ์ž๊ฐ€ ์ž…๋ ฅํ•˜๋Š” ๋Œ€๋กœ DOM์— ์ €์žฅ๋˜๋ฉฐ, ํ•„์š”ํ•  ๋•Œ๋งŒ ๊ฐ’์„ ์ฝ์–ด ์˜ต๋‹ˆ๋‹ค. + - React์˜ ์ƒํƒœ๋ฅผ ์‚ฌ์šฉํ•˜์ง€ ์•Š๊ธฐ ๋•Œ๋ฌธ์— ํผ์„ ๊ฐ„๋‹จํ•˜๊ฒŒ ์œ ์ง€ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. + + ```tsx + import { useRef } from 'react'; + + function UncontrolledInput() { + const inputRef = useRef(null); + + const handleSubmit = () => { + console.log(`์ž…๋ ฅ: ${inputRef.current.value}`); + }; + + return ( +
+ + +
+ ); + } + + export default UncontrolledInput; + + ``` + + ### ์žฅ์  + + - ์ƒํƒœ ๊ด€๋ฆฌ๊ฐ€ ํ•„์š” ์—†์œผ๋ฏ€๋กœ ๊ฐ„๋‹จํ•œ ํผ์— ์ ํ•ฉํ•˜๋ฉฐ, **`์„ฑ๋Šฅ์ ์œผ๋กœ๋„ ์œ ๋ฆฌ`**ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. + - ์ž‘์€ ํผ์ด๋‚˜ **`์ƒํƒœ๊ฐ€ ํ•„์š” ์—†๋Š” ๊ฒฝ์šฐ ์‚ฌ์šฉํ•˜๊ธฐ ์‰ฝ์Šต๋‹ˆ๋‹ค.`** + + ### ๋‹จ์  + + - ์ž…๋ ฅ ๊ฐ’์„ **`์‹ค์‹œ๊ฐ„์œผ๋กœ ๊ฒ€์ฆํ•˜๊ฑฐ๋‚˜ ์กฐ์ž‘ํ•˜๊ธฐ ์–ด๋ ค์šฐ๋ฉฐ`**, ํผ ๋ฐ์ดํ„ฐ์™€ ๊ด€๋ จ๋œ ๋…ผ๋ฆฌ๋ฅผ ๊ด€๋ฆฌํ•˜๋Š” ๋ฐ ์ œ์•ฝ์ด ์žˆ์„ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. + - **`DOM์— ์ง์ ‘ ์ ‘๊ทผ`**ํ•˜๊ธฐ ๋•Œ๋ฌธ์— **`React์˜ ๋‹จ๋ฐฉํ–ฅ ๋ฐ์ดํ„ฐ ํ๋ฆ„์„ ๋ฒ—์–ด๋‚˜๋Š” ๊ฒฝ์šฐ`**๊ฐ€ ์ƒ๊ธธ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. + + +### react-hook-form & yup ๐Ÿ  + +**`react-hook-form`**๊ณผ **`yup`**์€ React์—์„œ ํผ์„ ๊ฐ„ํŽธํ•˜๊ฒŒ ๊ด€๋ฆฌํ•˜๊ณ , ์œ ํšจ์„ฑ ๊ฒ€์‚ฌ๋ฅผ ์ˆ˜ํ–‰ํ•˜๋Š” ๋ฐ ์œ ์šฉํ•œ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ ์ž…๋‹ˆ๋‹ค. ๋‘ ๊ฐœ์˜ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ๋ฅผ ํ•จ๊ป˜ ์‚ฌ์šฉํ•˜๋ฉด, ํผ ์ž…๋ ฅ ๊ด€๋ฆฌ์™€ ๊ฒ€์ฆ ๊ณผ์ •์„ ๋งค์šฐ ํšจ์œจ์ ์œผ๋กœ ์ฒ˜๋ฆฌํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. + +ํ˜„์žฌ, ์—ฌ๊ธฐ์„œ๋Š” **`yup`**์„ ํ†ตํ•œ, **`validation`**์„ ์„ค๋ช…ํ•˜์ง€๋งŒ, ํ˜น์‹œ๋ผ๋„, ๋ณธ์ธ์ด ์ž‘์—…ํ•˜์‹œ๋Š” ํ”„๋กœ์ ํŠธ๊ฐ€ **`TypeScript`**์‹œ๋ผ๋ฉด, **`zod`**๋ฅผ ์‚ฌ์šฉํ•˜๋Š” ๊ฒƒ์ด ์กฐ๊ธˆ ๋” ์œ ๋ฆฌํ•  ์ˆ˜๋„ ์žˆ์œผ๋‹ˆ, **`zod`**๋ฅผ ๋”์šฑ ์ถ”์ฒœ๋“œ๋ฆฝ๋‹ˆ๋‹ค! + +https://tech.inflab.com/202207-rallit-form-refactoring/react-hook-form/ + +- **`react-hook-form`** ๊ณต์‹๋ฌธ์„œ ์„ค๋ช… + + ### react-hook-form + + https://react-hook-form.com/get-started + + ์ฃผ์š” ํŠน์ง• + + 1. DX (๊ฐœ๋ฐœ์ž ๊ฒฝํ—˜) + + ์ง๊ด€์ ์ด๊ณ , ๊ธฐ๋Šฅ์ด ์™„๋ฒฝํ•œ API๋กœ, ๊ฐœ๋ฐœ์ž๊ฐ€ ํผ์„ ๊ตฌ์ถ•ํ•  ๋–„ ๋งค๋„๋Ÿฌ์šด ๊ฒฝํ—˜์„ ์ œ๊ณตํ•ฉ๋‹ˆ๋‹ค. + + 2. HTML ํ‘œ์ค€ + + ๊ธฐ์กด์˜ HTML ๋งˆํฌ์—…์„ ํ™œ์šฉํ•˜์—ฌ ์ œ์•ฝ ๊ธฐ๋ฐ˜ ๊ฒ€์ฆ API๋กœ ํผ์„ ๊ฒ€์ฆํ•ฉ๋‹ˆ๋‹ค. + + 3. ๊ฐ€๋ฒผ์›€ + + ํŒจํ‚ค์ง€ ํฌ๊ธฐ๋Š” ๋งค์šฐ ์ค‘์š”ํ•ฉ๋‹ˆ๋‹ค. React Hook Form์€ ์˜์กด์„ฑ์ด ์—†๋Š” ์ž‘์€ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ์ด๋‹ค. + + 4. ์„ฑ๋Šฅ + + ๋ฆฌ๋ Œ๋”๋ง ํšŸ์ˆ˜๋ฅผ ์ตœ์†Œํ™”ํ•˜๊ณ , ๊ฒ€์ฆ ๊ณ„์‚ฐ์„ ์ค„์ด๋ฉฐ, ๋” ๋น ๋ฅธ ๋งˆ์šดํŒ…์„ ์ œ๊ณต. + + 5. ์ฑ„ํƒ ๊ฐ€๋Šฅ์„ฑ + + ํผ ์ƒํƒœ๋Š” ๋ณธ์งˆ์ ์œผ๋กœ ๋กœ์ปฌ์— ์žˆ๊ธฐ ๋–„๋ฌธ์— ๋‹ค๋ฅธ ์˜์กด์„ฑ ์—†์ด๋„ ์‰ฝ๊ฒŒ ์ฑ„ํƒ ๊ฐ€๋Šฅํ•˜๋‹ค. + + 6. UX (์‚ฌ์šฉ์ž ๊ฒฝํ—˜) + + ์ตœ์ƒ์˜ ์‚ฌ์šฉ์ž ๊ฒฝํ—˜์„ ์ œ๊ณตํ•˜๊ธฐ ์œ„ํ•ด ์ผ๊ด€๋œ ๊ฒ€์ฆ ์ „๋žต์„ ์ง€ํ–ฅ. + +- **`yup`** ๊ณต์‹๋ฌธ์„œ ์„ค๋ช… + + ### yup + + https://github.com/jquense/yup + + **`Yup`**์€ ๋Ÿฐํƒ€์ž„ ๊ฐ’ ํŒŒ์‹ฑ ๋ฐ ๊ฒ€์ฆ์„ ์œ„ํ•œ ์Šคํ‚ค๋งˆ ๋นŒ๋”์ž…๋‹ˆ๋‹ค. ์Šคํ‚ค๋งˆ๋ฅผ ์ •์˜ํ•˜๊ณ , ๊ฐ’์„ ๋ณ€ํ™˜ํ•˜์—ฌ ์ผ์น˜์‹œํ‚ค๊ฑฐ๋‚˜, ๊ธฐ์กด ๊ฐ’์˜ ํ˜•ํƒœ๋ฅผ ๊ฒ€์ฆํ•˜๊ฑฐ๋‚˜, ๋‘ ์ž‘์—…์„ ๋ชจ๋‘ ์ˆ˜ํ–‰ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. **`Yup ์Šคํ‚ค๋งˆ`**๋Š” ๋งค์šฐ ํ‘œํ˜„๋ ฅ์ด ๋›ฐ์–ด๋‚˜๋ฉฐ ๋ณต์žกํ•˜๊ณ  ์ƒํ˜ธ ์˜์กด์ ์ธ ๊ฒ€์ฆ์ด๋‚˜ ๊ฐ’ ๋ณ€ํ™˜์„ ๋ชจ๋ธ๋งํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. + + ์ฃผ์š” ๊ธฐ๋Šฅ: + + 1. ๊ฐ„๊ฒฐํ•˜๋ฉด์„œ๋„ ํ‘œํ˜„๋ ฅ์ด ๋›ฐ์–ด๋‚œ ์Šคํ‚ค๋งˆ ์ธํ„ฐํŽ˜์ด์Šค๋กœ, ๊ฐ„๋‹จํ•œ ๋ฐ์ดํ„ฐ ๋ชจ๋ธ๋ถ€ํ„ฐ ๋ณต์žกํ•œ ๋ฐ์ดํ„ฐ ๋ชจ๋ธ๊นŒ์ง€ ์„ค๊ณ„ ๊ฐ€๋Šฅ + 2. ๊ฐ•๋ ฅํ•œ TypeScript ์ง€์›: ์Šคํ‚ค๋งˆ์—์„œ ์ •์  ํƒ€์ž…์„ ์ถ”๋ก ํ•˜๊ฑฐ๋‚˜, ์Šคํ‚ค๋งˆ๊ฐ€ ์˜ฌ๋ฐ”๋ฅด๊ฒŒ ํƒ€์ž…์„ ๊ตฌํ˜„ํ•˜๋Š”์ง€ ํ™•์ธ + 3. ๋‚ด์žฅ๋œ ๋น„๋™๊ธฐ ๊ฒ€์ฆ ์ง€์›: ์„œ๋ฒ„ ์ธก ๋ฐ ํด๋ผ์ด์–ธํŠธ ์ธก ๊ฒ€์ฆ์„ ๋™์ผํ•˜๊ฒŒ ๋ชจ๋ธ๋ง ๊ฐ€๋Šฅ + 4. ํ™•์žฅ์„ฑ: ํƒ€์ž… ์•ˆ์ •์„ฑ์ด ๋ณด์žฅ๋œ ๋ฉ”์„œ๋“œ์™€ ์Šคํ‚ค๋งˆ๋ฅผ ์ถ”๊ฐ€ํ•  ์ˆ˜ ์žˆ์Œ + 5. ํ’๋ถ€ํ•œ ์˜ค๋ฅ˜ ์„ธ๋ถ€ ์ •๋ณด ์ œ๊ณต์œผ๋กœ ๋””๋ฒ„๊น…์ด ์‰ฌ์›€ +- **react-hook-form & yup validation ์‹ค์Šต ๐Ÿ ** + + ### ์‹ค์Šต + + ์•„๋ž˜์™€ ๊ฐ™์ด **`๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ๋ฅผ ์„ค์น˜`**ํ•ด์ค๋‹ˆ๋‹ค. + + ```tsx + yarn add react-hook-form yup + ``` + + ๊ทธ ์ดํ›„ **`useForm`** hook์„ ๋ถˆ๋Ÿฌ์˜ต๋‹ˆ๋‹ค. + + ```tsx + import {useForm} from 'react-hook-form' + + const SignUpPage = () => { + const {register, handleSubmit} = useForm(); + + const onSubmit = () => { + console.log('ํผ ๋ฐ์ดํ„ฐ ์ œ์ถœ') + } + + return ( +
+ + + +
+ ); + }; + + export default SignUpPage; + + ``` + + 1. **`register`**๋ฅผ ํ†ตํ•ด์„œ, ๊ฐ **`input`**์— ์—ฐ๊ฒฐํ•ด์ค๋‹ˆ๋‹ค. ์ด ๋–„ **`spread operator`**๋ฅผ ํ†ตํ•ด์„œ, ์›ํ•˜๋Š” **`name`**๊ณผ ํ•จ๊ป˜ ์—ฐ๊ฒฐ์„ ํ•ด์ฃผ๋ฉด ๋œ๋‹ค๊ณ  ์ดํ•ดํ•˜์‹œ๋ฉด ๋ฉ๋‹ˆ๋‹ค. + 2. form ํƒœ๊ทธ ์•ˆ์—๋Š” ์ž์ฒด์ ์œผ๋กœ **`onSubmit`** ๋‚ด๋ถ€์— ํ•จ์ˆ˜๋ฅผ ์—ฐ๊ฒฐํ•ด์ค„ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ์ด ๋–„, **`useForm`** Hook์—์„œ ์ œ๊ณตํ•ด์ฃผ๋Š” **`handleSubmit`**์„ ์—ฐ๊ฒฐํ•ด์ฃผ๊ณ , ์ž์ฒด์ ์œผ๋กœ **`onSubmit`** ํ•จ์ˆ˜๋ฅผ ํ†ตํ•ด์„œ, data๋ฅผ ์ „๋‹ฌ ๋ฐ›์•„, **`data ํ˜ธ์ถœ`**ํ•˜๋ฉด ๋ฉ๋‹ˆ๋‹ค. + + ```tsx + import {useForm} from 'react-hook-form' + + const SignUpPage = () => { + const {register, handleSubmit} = useForm(); + + const onSubmit = (data) => { + console.log('ํผ ๋ฐ์ดํ„ฐ ์ œ์ถœ') + console.log(data); + } + + return ( +
+ + + +
+ ); + }; + + export default SignUpPage; + + ``` + + ์ œ๊ฐ€ ๋งŒ์•ฝ **`formData`**์˜ **`register`**์— ์•„๋ž˜์™€ ๊ฐ™์ด **`email`**, **`password`** ๋ผ๋Š” ์ด๋ฆ„์œผ๋กœ, ์—ฐ๊ฒฐํ–ˆ์œผ๋‹ˆ ์•„๋ž˜์™€ ๊ฐ™์ด ๋ฐ์ดํ„ฐ๊ฐ€ ์ถœ๋ ฅ๋ฉ๋‹ˆ๋‹ค. + + ![แ„‰แ…ณแ„แ…ณแ„…แ…ตแ†ซแ„‰แ…ฃแ†บ 2024-09-17 แ„‹แ…ฉแ„’แ…ฎ 4.12.51.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/f1912130-0409-4e90-a90f-6091ae253e73/e2a62981-5cb1-4703-aed2-d758f6bde89d/%E1%84%89%E1%85%B3%E1%84%8F%E1%85%B3%E1%84%85%E1%85%B5%E1%86%AB%E1%84%89%E1%85%A3%E1%86%BA_2024-09-17_%E1%84%8B%E1%85%A9%E1%84%92%E1%85%AE_4.12.51.png) + + ์šฐ๋ฆฌ๊ฐ€ ์œ„์—์„œ, ์„ค๋ช…ํ•˜๊ธฐ์—๋Š” **`yup`**์„ ํ™œ์šฉํ•ด์„œ, ์œ ํšจ์„ฑ ๊ฒ€์‚ฌ๋ฅผ ์ง„ํ–‰ํ•œ๋‹ค๊ณ  ํ–ˆ์Šต๋‹ˆ๋‹ค. ์ด๋ฅผ ํ•˜๊ธฐ ์œ„ํ•ด์„œ๋Š” ์šฐ๋ฆฌ๊ฐ€ ๋งŒ๋“ , **`schema`**๋ฅผ **`resolve`** ํ•˜๋Š” ๊ณผ์ •์ด ํ•„์š”ํ•œ๋ฐ, ์ด๋ฅผ ์œ„ํ•ด ์•„๋ž˜ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ๊ฐ€ ํ•˜๋‚˜ ๋” ํ•„์š”ํ•ฉ๋‹ˆ๋‹ค. + + ```tsx + yarn add @hookform/resolvers + ``` + + ๋จผ์ €, ์ด๋ฉ”์ผ๊ณผ ๋น„๋ฐ€๋ฒˆํ˜ธ ๊ด€๋ จํ•ด์„œ **`schema`**๋ฅผ ์ƒ์„ฑํ•ด๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค. ์—ฌ๊ธฐ์„œ ๋งํ•˜๋Š” **`schema`**๋Š” ์‰ฝ๊ฒŒ ์ƒ๊ฐํ•ด์„œ **`์œ ํšจ์„ฑ ๊ฒ€์‚ฌ`**๋ผ๊ณ  ์ƒ๊ฐํ•˜์‹œ๋ฉด ๋ฉ๋‹ˆ๋‹ค. + + ์šฐ๋ฆฌ์˜ **`ํšŒ์›๊ฐ€์ž… ์œ ํšจ์„ฑ ๊ฒ€์‚ฌ ์กฐ๊ฑด`**์€ ์•„๋ž˜์™€ ๊ฐ™๋‹ค๋Š” ๊ฐ€์ •ํ•˜์— ์ง„ํ–‰ํ•ด๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค. + + ### ์ด๋ฉ”์ผ ์œ ํšจ์„ฑ ๊ฒ€์‚ฌ ์กฐ๊ฑด + + - [x] ๋ฌธ์ž์—ด์ด์–ด์•ผ ํ•œ๋‹ค. + - [x] ํ•„์ˆ˜๋กœ ์ž…๋ ฅ๋˜์–ด์•ผ ํ•œ๋‹ค. + + ### ๋น„๋ฐ€๋ฒˆํ˜ธ ์œ ํšจ์„ฑ ๊ฒ€์‚ฌ ์กฐ๊ฑด + + - [x] ๋ฌธ์ž์—ด์ด์–ด์•ผ ํ•œ๋‹ค. + - [x] ์ตœ์†Œ 8๊ธ€์ž์ด์–ด์•ผ ํ•œ๋‹ค. + - [x] ์ตœ๋Œ€ 16์ž์ด์–ด์•ผ ํ•œ๋‹ค. + - [x] ํ•„์ˆ˜๋กœ ์ž…๋ ฅ๋˜์–ด์•ผ ํ•œ๋‹ค. + + **`yup`**์˜ **`object`**๋ฅผ ํ†ตํ•ด, **`schema`**์˜ **`shape์„ ์ •์˜`**ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. + + ```tsx + import {useForm} from 'react-hook-form' + import * as yup from 'yup' + // TIP: zod๋ฅผ ์‚ฌ์šฉํ•˜์‹ ๋‹ค๋ฉด @hookform/resolvers/zod ๋ฅผ import ํ•˜์‹œ๋ฉด ๋ฉ๋‹ˆ๋‹ค! + import {yupResolver} from '@hookform/resolvers/yup' + + const SignUpPage = () => { + const schema = yup.object().shape({ + email: yup.string().email().required(), + password: yup.string().min(8).max(16).required(), + }) + + const {register, handleSubmit} = useForm(); + + const onSubmit = (data) => { + console.log('ํผ ๋ฐ์ดํ„ฐ ์ œ์ถœ') + console.log(data); + } + + return ( +
+ + + +
+ ); + }; + + export default SignUpPage; + + ``` + + ์‹ค์ œ๋กœ, ์ด๋ ‡๊ฒŒ ํ•˜๋ฉด ์ ์šฉ์ด ๋˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค. ์ถ”๊ฐ€์ ์ธ ์ฒ˜๋ฆฌ๋ฅผ ํ•ด์ฃผ์–ด์•ผ ํ•ฉ๋‹ˆ๋‹ค. ์šฐ๋ฆฌ๊ฐ€, ์œ„์—์„œ ํŒจํ‚ค์ง€๋กœ ์„ค์น˜ํ•œ **`yupResolver`**๋ฅผ ํ†ตํ•ด, ์šฐ๋ฆฌ๊ฐ€ ๋งŒ๋“  **`schema`**๋ฅผ ์—ฐ๊ฒฐ์‹œ์ผœ์ฃผ๋ฉด ๋ฉ๋‹ˆ๋‹ค. + + ```tsx + const {register, handleSubmit} = useForm({ + resolver: yupResolver(schema) + }); + ``` + + ๊ทธ๋Ÿผ ์ด์ œ ์œ ํšจ์„ฑ ๊ฒ€์‚ฌ๊ฐ€ ๋งค์šฐ ์ž˜๋˜๋Š” ๊ฒƒ์„ ํ™•์ธํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. + + ์—๋Ÿฌ ๋ฉ”์‹œ์ง€๋ฅผ ํ™•์ธํ•˜๊ณ  ์‹ถ์œผ์‹œ๋ฉด, **`useForm`** hook์—์„œ **`formState`**๋ฅผ ์ถ”๊ฐ€๋กœ ๋ถˆ๋Ÿฌ์™€์•ผ ํ•ฉ๋‹ˆ๋‹ค. + + ```tsx + const {register, handleSubmit, formState: {errors}} = useForm({ + resolver: yupResolver(schema) + }); + ``` + + ์•„๋ž˜์™€ ๊ฐ™์ด ์ „์ฒด ์ฝ”๋“œ๋ฅผ ๊ตฌ์„ฑํ•˜๋ฉด ์—๋Ÿฌ๋ฉ”์‹œ์ง€๋ฅผ ๋ณผ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. + + ```tsx + import {useForm} from 'react-hook-form' + import * as yup from 'yup' + import {yupResolver} from '@hookform/resolvers/yup' + + const SignUpPage = () => { + const schema = yup.object().shape({ + email: yup.string().email().required(), + password: yup.string().min(8).max(16).required(), + }) + + const {register, handleSubmit, formState: {errors}} = useForm({ + resolver: yupResolver(schema) + }); + + const onSubmit = (data) => { + console.log('ํผ ๋ฐ์ดํ„ฐ ์ œ์ถœ') + console.log(data); + } + + return ( +
+ + // register ํ•œ ์ด๋ฆ„์— ๋งž๊ฒŒ ์—ฐ๊ฒฐํ•ด์ฃผ์„ธ์š”! +

{errors.email?.message}

+ +

{errors.password?.message}

+ +
+ ); + }; + + export default SignUpPage; + + ``` + + ![แ„‰แ…ณแ„แ…ณแ„…แ…ตแ†ซแ„‰แ…ฃแ†บ 2024-09-17 แ„‹แ…ฉแ„’แ…ฎ 5.07.41.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/f1912130-0409-4e90-a90f-6091ae253e73/6b74818d-e5d1-4b3f-b151-04c085b46578/%E1%84%89%E1%85%B3%E1%84%8F%E1%85%B3%E1%84%85%E1%85%B5%E1%86%AB%E1%84%89%E1%85%A3%E1%86%BA_2024-09-17_%E1%84%8B%E1%85%A9%E1%84%92%E1%85%AE_5.07.41.png) + + ์œ„์™€ ๊ฐ™์ด ์—๋Ÿฌ๋ฉ”์‹œ์ง€๊ฐ€, ๋‚˜์˜ต๋‹ˆ๋‹ค. ํ•˜์ง€๋งŒ, ์šฐ๋ฆฌ๋Š” ํ•œ๊ตญ์ธ์ด๊ธฐ์—, ์˜์–ด๋กœ ๋œ ์—๋Ÿฌ๋ฉ”์‹œ์ง€๋ฅผ ์›ํ•˜๋Š” ์‚ฌ๋žŒ์€ ๋งŽ์ง€ ์•Š์„ ๊ฒƒ ์ž…๋‹ˆ๋‹ค. + + **`์ปค์Šคํ…€ ์—๋Ÿฌ ๋ฉ”์‹œ์ง€ ๋˜ํ•œ ์„ ์–ธ`**ํ•ด์ค„ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. + + ```tsx + const schema = yup.object().shape({ + email: yup.string().email().required('์ด๋ฉ”์ผ์„ ๋ฐ˜๋“œ์‹œ ์ž…๋ ฅํ•ด์ฃผ์„ธ์š”.'), + password: yup.string().min(8, '๋น„๋ฐ€๋ฒˆํ˜ธ๋Š” 8์ž ์ด์ƒ์ด์–ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.').max(16, '๋น„๋ฐ€๋ฒˆํ˜ธ๋Š” 16์ž ์ดํ•˜์—ฌ์•ผ ํ•ฉ๋‹ˆ๋‹ค.').required(), + }) + ``` + + ![แ„‰แ…ณแ„แ…ณแ„…แ…ตแ†ซแ„‰แ…ฃแ†บ 2024-09-17 แ„‹แ…ฉแ„’แ…ฎ 5.09.24.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/f1912130-0409-4e90-a90f-6091ae253e73/7b8d8f7d-4579-4511-928d-495857e9990e/%E1%84%89%E1%85%B3%E1%84%8F%E1%85%B3%E1%84%85%E1%85%B5%E1%86%AB%E1%84%89%E1%85%A3%E1%86%BA_2024-09-17_%E1%84%8B%E1%85%A9%E1%84%92%E1%85%AE_5.09.24.png) + + ํŠน์ • ์กฐ๊ฑด์— ๋งž์ง€ ์•Š๋Š”๊ฒฝ์šฐ์— ์šฐ๋ฆฌ๊ฐ€ **`์ง€์ •ํ•œ ์ปค์Šคํ…€ ์—๋Ÿฌ`**๋ฅผ ๋„˜๊ฒจ์ค„ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. + + +# โœ…ย ์‹ค์Šต 1. - ๋กœ๊ทธ์ธ ํŽ˜์ด์ง€ ์œ ํšจ์„ฑ ๊ฒ€์‚ฌ ๊ตฌํ˜„ ๐Ÿ  + + + +![แ„‰แ…ณแ„แ…ณแ„…แ…ตแ†ซแ„‰แ…ฃแ†บ 2024-09-16 แ„‹แ…ฉแ„’แ…ฎ 9.28.39.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/f1912130-0409-4e90-a90f-6091ae253e73/f848035a-91b4-4f6a-8738-78d927da4e4f/%E1%84%89%E1%85%B3%E1%84%8F%E1%85%B3%E1%84%85%E1%85%B5%E1%86%AB%E1%84%89%E1%85%A3%E1%86%BA_2024-09-16_%E1%84%8B%E1%85%A9%E1%84%92%E1%85%AE_9.28.39.png) + +### UI + +- [x] ์ด๋ฉ”์ผ๊ณผ, ๋น„๋ฐ€๋ฒˆํ˜ธ **`type`**์˜ **`input`**์„ 2๊ฐœ ๋งŒ๋“ค์–ด์ฃผ์„ธ์š”. +- [x] ๋ชจ๋“  ๊ฐ’์„ ์ž…๋ ฅํ•œ ํ›„, ๋กœ๊ทธ์ธ ํ•  ์ˆ˜ ์žˆ๋Š” **`๋กœ๊ทธ์ธ ๋ฒ„ํŠผ`**์„ ๋งŒ๋“ค์–ด์ฃผ์„ธ์š”. + +[แ„’แ…ชแ„†แ…งแ†ซ แ„€แ…ตแ„…แ…ฉแ†จ 2024-09-17 แ„‹แ…ฉแ„’แ…ฎ 3.31.03.mov](https://prod-files-secure.s3.us-west-2.amazonaws.com/f1912130-0409-4e90-a90f-6091ae253e73/b4fd6547-f18d-4d29-bf8d-d77cbeb5ef1b/%E1%84%92%E1%85%AA%E1%84%86%E1%85%A7%E1%86%AB_%E1%84%80%E1%85%B5%E1%84%85%E1%85%A9%E1%86%A8_2024-09-17_%E1%84%8B%E1%85%A9%E1%84%92%E1%85%AE_3.31.03.mov) + +### ๊ธฐ๋Šฅ ์ฒดํฌ + +- [x] ์ด๋ฉ”์ผ์€ **`์˜ฌ๋ฐ”๋ฅธ ์ด๋ฉ”์ผ ํ˜•์‹์ด ์•„๋‹ ๊ฒฝ์šฐ`**, ์œ„์™€ ๊ฐ™์ด ์—๋Ÿฌ ๋ฉ”์‹œ์ง€์™€, UI์ƒ ๋ณ€ํ™”๊ฐ€ ๋‚˜ํƒ€๋‚˜๋„๋ก, ๊ตฌํ˜„ํ•ด์ฃผ์„ธ์š”. +- [x] ๋น„๋ฐ€๋ฒˆํ˜ธ๋„, **`8์ž๋ฆฌ ์ด์ƒ 16์ž๋ฆฌ ์ดํ•˜๊ฐ€ ์•„๋‹Œ ๊ฒฝ์šฐ`**, ์—๋Ÿฌ๋ฉ”์‹œ์ง€๊ฐ€ ๋‚˜์˜ค๊ฒŒ ๊ตฌํ˜„ํ•ด์ฃผ์„ธ์š”. +- [x] ์—๋Ÿฌ ๋ฉ”์‹œ์ง€๋Š”, **`์‹ค์‹œ๊ฐ„์œผ๋กœ ์กฐ๊ฑด์ด ์ถฉ์กฑํ•˜๋ฉด, ์‚ฌ๋ผ์ ธ์•ผ ํ•ฉ๋‹ˆ๋‹ค.`** +- [x] ์‹ค์ œ๋กœ, **`input ์ฐฝ์„ ํด๋ฆญํ–ˆ์„ ๊ฒฝ์šฐ`**, **`์—๋Ÿฌ๋ฉ”์‹œ์ง€๊ฐ€ ๋‚˜์˜ค๊ฒŒ ๋™์ž‘`**ํ•ด์ฃผ์„ธ์š”. input ์ฐฝ์„ ๋ˆ„๋ฅด์ง€๋„ ์•Š์•˜๋Š”๋ฐ, ๋ฐ”๋กœ ์—๋Ÿฌ๋ฉ”์‹œ์ง€๊ฐ€ ๋‚˜์˜ค๋ฉด, UX ์ธก๋ฉด์—์„œ ๊ธฐ๋ถ„ ์ข‹์ง€ ์•Š๊ฒ ์ฃ ? + +### ์ด๊ฒƒ๋„ ํ•ด๋ณด๋ฉด ์ข‹์•„์š” + +- [x] **`๋ชจ๋“  ์กฐ๊ฑด์„ ์ถฉ์กฑํ•˜์ง€ ์•Š์•˜์„ ๋–„๋Š”, ๋กœ๊ทธ์ธ ๋ฒ„ํŠผ์„ gray ์ƒ‰์ƒ์œผ๋กœ ๋น„ํ™œ์„ฑํ™” ๋˜๊ฒŒ ํ•ด์ฃผ์„ธ์š”.`** (disabled props ํ™œ์šฉ) + - [x] ์‹ค์ œ๋กœ, ๋ฒ„ํŠผ ๋™์ž‘๋„ ๋น„ํ™œ์„ฑํ™” ๋˜์–ด์•ผ ํ•ฉ๋‹ˆ๋‹ค. + - [x] ๋‹จ ์กฐ๊ฑด ์ถฉ์กฑ์‹œ, ์›๋ž˜ ์ƒ‰์ƒ(ํ•‘ํฌ)๋กœ ์ƒ‰์ƒ์ด ๋ณ€๊ฒฝ๋˜๊ฒŒ ํ•ฉ๋‹ˆ๋‹ค. + +### ์‹ค์Šต 1 ์ œ์ถœ + +- ์‹ค์Šต 1 ๊นƒํ—ˆ๋ธŒ ๋งํฌ ์ œ์ถœ + + https://github.com/RyuDongHo/UmcWeb/tree/main/mission/chapter05/mission + +- ์‹ค์Šต 1 ์‹คํ–‰ ์˜์ƒ ์ œ์ถœ + + [1.mp4](https://prod-files-secure.s3.us-west-2.amazonaws.com/f1912130-0409-4e90-a90f-6091ae253e73/0cd283dd-ccc8-496b-8919-5000b6813d9d/1.mp4) + + +# โœ…ย ์‹ค์Šต 2. useForm Hook์„ ํ†ตํ•œ ์œ ํšจ์„ฑ ๊ฒ€์‚ฌ ๐Ÿ  + + + +https://www.youtube.com/watch?v=gWSAYvBH16I + +### ๊ตฌํ˜„ ์œ ์˜์‚ฌํ•ญ + +- [x] **`useForm`** hook์„ ์‚ฌ์šฉํ–ˆ๋Š”๊ฐ€? + +### ์‹ค์Šต 2 ์ œ์ถœ + +- ์‹ค์Šต 2 ๊นƒํ—ˆ๋ธŒ ๋งํฌ ์ œ์ถœ + + https://github.com/RyuDongHo/UmcWeb/tree/main/mission/chapter05/mission + +- ์‹ค์Šต 2 ์‹คํ–‰ ์˜์ƒ ์ œ์ถœ + + + +# ๐Ÿ”ฅย ๋ฏธ์…˜ - ํšŒ์› ๊ฐ€์ž… ํŽ˜์ด์ง€ ์ œ์ž‘ ๐Ÿ  + + + +![แ„‰แ…ณแ„แ…ณแ„…แ…ตแ†ซแ„‰แ…ฃแ†บ 2024-09-17 แ„‹แ…ฉแ„’แ…ฎ 5.24.27.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/f1912130-0409-4e90-a90f-6091ae253e73/067e2dad-e8d9-4200-bdce-208932d73547/%E1%84%89%E1%85%B3%E1%84%8F%E1%85%B3%E1%84%85%E1%85%B5%E1%86%AB%E1%84%89%E1%85%A3%E1%86%BA_2024-09-17_%E1%84%8B%E1%85%A9%E1%84%92%E1%85%AE_5.24.27.png) + +### ์œ ํšจ์„ฑ ๊ฒ€์‚ฌ ์กฐ๊ฑด + +- [x] **`Email`** input์„ ๋งŒ๋“ค์–ด์ค๋‹ˆ๋‹ค. + - [x] ๋ฌธ์ž์—ด์ด์–ด์•ผ ํ•ฉ๋‹ˆ๋‹ค. + - [x] ์œ ํšจํ•œ ์ด๋ฉ”์ผ ํ˜•์‹์ด์–ด์•ผ ํ•ฉ๋‹ˆ๋‹ค. + - [x] ์ด๋ฉ”์ผ์€ ํ•„์ˆ˜ ์ž…๋ ฅ์š”์†Œ์ž…๋‹ˆ๋‹ค. +- [x] **`Password`** input์„ ๋งŒ๋“ค์–ด์ค๋‹ˆ๋‹ค. + - [x] ๋ฌธ์ž์—ด์ด์–ด์•ผ ํ•ฉ๋‹ˆ๋‹ค. + - [x] ๋น„๋ฐ€๋ฒˆํ˜ธ๋Š” 8์ž ์ด์ƒ์ด์–ด์•ผ ํ•ฉ๋‹ˆ๋‹ค. + - [x] ๋น„๋ฐ€๋ฒˆํ˜ธ๋Š” 16์ž ์ดํ•˜์—ฌ์•ผ ํ•ฉ๋‹ˆ๋‹ค. + - [x] ๋น„๋ฐ€๋ฒˆํ˜ธ๋Š” ํ•„์ˆ˜ ์ž…๋ ฅ์š”์†Œ์ž…๋‹ˆ๋‹ค. +- [x] **`PasswordCheck`** input์„ ๋งŒ๋“ค์–ด์ค๋‹ˆ๋‹ค. + - [x] **`Password input์— ๋“ค์–ด๊ฐ„ ์š”์†Œ`**์™€, **`PasswordCheck input ์š”์†Œ`**์— ๋“ค์–ด๊ฐ„ ์š”์†Œ์˜ **`value๊ฐ€ ๋‹ค๋ฅผ๋•Œ`** **`๋น„๋ฐ€๋ฒˆํ˜ธ๊ฐ€ ์ผ์น˜ํ•˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค. ๋ผ๋Š” ์—๋Ÿฌ๊ฐ€ ๋ฐœ์ƒ`**ํ•ฉ๋‹ˆ๋‹ค. + - [x] ๋น„๋ฐ€๋ฒˆํ˜ธ ๊ฒ€์ฆ์€ ํ•„์ˆ˜ ์ž…๋ ฅ ์š”์†Œ์ž…๋‹ˆ๋‹ค. + +### ๊ตฌํ˜„ ์œ ์˜ ์‚ฌํ•ญ + +- [x] **`Input`** ์ปดํฌ๋„ŒํŠธ๋ฅผ ๋งŒ๋“ค์–ด ์ž˜ ํ™œ์šฉํ–ˆ๋Š”๊ฐ€? +- [x] **`react-hook-form`** ๊ณผ **`yup`**์˜ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ๋ฅผ ์ž˜ ํ™œ์šฉํ–ˆ๋Š”๊ฐ€? +- [x] ๋ชจ๋“  input์˜ value๊ฐ€, ์›ํ•˜๋Š” **`{ key: value }`** ํ˜•ํƒœ๋กœ ์ž˜ ์ถœ๋ ฅ๋˜์—ˆ๋Š”๊ฐ€? + +### ์ด๊ฒƒ๋„ ํ•ด๋ณด๋ฉด ์ข‹์•„์š” (ํ•„์ˆ˜ X) + +- [x] ์‹ค์Šต 2์—์„œ ํ•จ๊ป˜ ๋งŒ๋“  **`useForm hook์„ ํ™œ์šฉ`**ํ•ด์„œ, ์œ„์˜ ๋‚ด์šฉ์„ ๋™์ผํ•˜๊ฒŒ ๋งŒ๋“ค์–ด๋ณด์„ธ์š”! + - **`useForm`** Hook์œผ๋กœ ๋งŒ๋“ , ๊นƒํ—ˆ๋ธŒ ๋งํฌ ์ œ์ถœ + - **`useForm`** Hook์œผ๋กœ ๋งŒ๋“ , ์‹คํ–‰ ์˜์ƒ ์ œ์ถœ +- [ ] ์„ฑ๋ณ„์ด๋‚˜, ์ƒ๋…„์›”์ผ ๋“ฑ **`์‹ค์ œ๋กœ ์žˆ์„ ๋ฒ•ํ•œ Form ์š”์†Œ๋“ค์„ ๋งŒ๋“ค์–ด, ์ถ”๊ฐ€์ ์œผ๋กœ ๋” ๋งŒ๋“ค์–ด๋ณด์‹œ๊ณ  ์Šคํ„ฐ๋””์›๋“ค๊ณผ ๊ณต์œ `**ํ•ด๋ณด์„ธ์š”! +- [ ] **`zod`** ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ๋„ ํ•œ๋ฒˆ ์‚ฌ์šฉํ•ด๋ณด์„ธ์š”! + +### ๋ฏธ์…˜ ์ œ์ถœ + +- ์‹ค์Šต 2 ๊นƒํ—ˆ๋ธŒ ๋งํฌ ์ œ์ถœ + + https://github.com/RyuDongHo/UmcWeb/tree/main/mission/chapter05/mission + +- ์‹ค์Šต 2 ์‹คํ–‰ ์˜์ƒ ์ œ์ถœ + + [2.mp4](https://prod-files-secure.s3.us-west-2.amazonaws.com/f1912130-0409-4e90-a90f-6091ae253e73/7d5c159a-73b5-4d0d-a3d9-d6303b926ae0/2.mp4) \ No newline at end of file diff --git a/keyword/chapter06/keyword.md b/keyword/chapter06/keyword.md new file mode 100644 index 0000000..816b393 --- /dev/null +++ b/keyword/chapter06/keyword.md @@ -0,0 +1,337 @@ +# ๐Ÿ“ย ํ•™์Šต ๋ชฉํ‘œ + +--- + +1. **`QueryParameter`**๋ฅผ ํ™œ์šฉํ•˜์—ฌ, ๊ฒ€์ƒ‰ ๊ธฐ๋Šฅ์„ ๊ตฌํ˜„ํ•ด๋ด…๋‹ˆ๋‹ค. +2. **`Debounce`**์™€ **`Throttling`**์ด ๋ฌด์—‡์ธ์ง€ ์•Œ์•„๋ณด๊ณ , ์ด๋ฅผ ์‹ค์ œ ํ”„๋กœ์ ํŠธ์— ์ ์šฉํ•ด๋ด…๋‹ˆ๋‹ค. +3. **`useContext`**๋ฅผ ํ™œ์šฉํ•˜์—ฌ, ์ „์—ญ ์ƒํƒœ ๊ด€๋ฆฌ๋ฅผ ํ•˜๋Š” ์ด์œ ์™€, ๊ธฐ์กด ์ฝ”๋“œ ๋ฆฌํŒฉํ† ๋ง์„ ์ง„ํ–‰ํ•ด๋ด…๋‹ˆ๋‹ค. +4. **`AccessToken`**๊ณผ **`RefreshToken`**์„ ํ™œ์šฉํ•œ ๋กœ๊ทธ์ธ ๋ฐฉ์‹์— ๋Œ€ํ•ด ํ•™์Šตํ•ฉ๋‹ˆ๋‹ค. + +# โš ๏ธย ย ์Šคํ„ฐ๋”” ์ง„ํ–‰ ๋ฐฉ๋ฒ• + +--- + +1. ์Šคํ„ฐ๋””๋ฅผ ์ง„ํ–‰ํ•˜๊ธฐ ์ „, ์›Œํฌ๋ถ ๋‚ด์šฉ๋“ค์„ ๋ชจ๋‘ ์ฑ„์šฐ๊ณ  ์Šคํ„ฐ๋””์—์„œ ์„œ๋กœ ๋ชจ๋ฅด๋Š” ๋‚ด์šฉ๋“ค์„ ์Šคํ„ฐ๋””์›๊ณผ ํ•จ๊ป˜ ๊ณต์œ ํ•ด ์ฃผ์„ธ์š”. +2. ์‹ค์Šต๊ณผ ๋ฏธ์…˜์€ ์›Œํฌ๋ถ ๋‚ด์šฉ๋“ค์„ ๋ชจ๋‘ ์™„๋ฃŒํ•œ ํ›„, ์Šคํ„ฐ๋”” ์ „์— ์ง„ํ–‰ํ•ด ์˜ค์„ธ์š”! + - 1์ฃผ ์ฐจ ์Šคํ„ฐ๋”” ์ด์ „์— 1์ฃผ ์ฐจ ์›Œํฌ๋ถ์„ ์™„์„ฑํ•œ ํ›„ ์Šคํ„ฐ๋””๋ฅผ ์ง„ํ–‰ํ•ด ์ฃผ์„ธ์š”. +3. ์Šคํ„ฐ๋”” ์‹œ๊ฐ„์—๋Š” ๊ฐ์ž ํ•ด ์˜จ ๋ฏธ์…˜๋“ค์„ ๊ณต์œ ํ•˜๊ณ , ์•„๋ž˜์˜ ๊ณผ์ •์„ ์ง„ํ–‰ํ•ฉ๋‹ˆ๋‹ค. + 1. ์Šคํ„ฐ๋””์›๊ณผ ํ•จ๊ป˜ ์ฝ”๋“œ ๋ฆฌ๋ทฐ ์ง„ํ–‰. + 2. ์ฝ”๋“œ ๋ฆฌ๋ทฐ ์ดํ›„, ๋ณธ์ธ์˜ ์ฝ”๋“œ์˜ ๋ฌธ์ œ๊ฐ€ ์žˆ๋Š” ๊ฒฝ์šฐ ๋ฆฌํŒฉํ† ๋ง ์ง„ํ–‰. + 3. ํŒ€์›๋“ค๊ณผ, ์กฐ๊ธˆ ๋” ์ฝ”๋“œ๋ฅผ ๊น”๋”ํ•˜๊ฒŒ ์ž‘์„ฑํ•  ์ˆ˜ ์žˆ๋Š” ๊ฐœ์„ ์ ์ด ์žˆ์„์ง€ ๊ณ ๋ฏผ ํ›„, ๋ฆฌํŒฉํ† ๋ง ์ง„ํ–‰. + 4. ๊ฐ์ž ๋ฏธ์…˜์„ ์ง„ํ–‰ํ•˜๋ฉด์„œ ํ•ด๊ฒฐํ•˜์ง€ ๋ชปํ•œ ์ด์Šˆ๋ฅผ ๊ณต์œ  ํ›„, ํ•ด๋‹น ์ด์Šˆ๋ฅผ ๋„์›€๋ฐ›์•„ ํ•ด๊ฒฐ. +4. ๋งค์ฃผ ์ฃผ์–ด์ง„ ๋ฏธ์…˜์„ ์„ฑ์‹คํ•˜๊ฒŒ ์ œ์ถœํ•ฉ๋‹ˆ๋‹ค. +5. ๐Ÿ ย ์ด๋ชจ์ง€๊ฐ€ ๋ถ™์–ด์žˆ๋Š” ๊ณณ์€, ์ง์ ‘ ์—ฌ๋Ÿฌ๋ถ„๋“ค์ด ์ฑ„์›Œ ๋„ฃ์œผ์…”์•ผ ํ•˜๋Š” ๋ถ€๋ถ„์ž…๋‹ˆ๋‹ค. ๊ผญ Google์„ ํ†ตํ•œ ๊ฒ€์ƒ‰์„ ํ•˜์‹œ๊ณ , VSCode๋ฅผ ํ™œ์šฉํ•˜์—ฌ, ์‹คํ–‰ ๊ฒฐ๊ณผ๋ฅผ ๋ˆˆ์œผ๋กœ ๋ณด์‹œ๋ฉด์„œ ์ •๋ฆฌํ•ด ์ฃผ์„ธ์š”! + +# ๐Ÿ“ธย ์ž ๊น ! ์Šคํ„ฐ๋”” ์ธ์ฆ์ƒท์€ ์ฐ์œผ์…จ๋‚˜์š”?๐Ÿ“ธ + +--- + +* ์Šคํ„ฐ๋””๋ฆฌ๋”๊ป˜์„œ ๋Œ€ํ‘œ๋กœ ๋งค ์ฃผ์ฐจ๋งˆ๋‹ค ํ•œ ์žฅ ๋‚จ๊ฒจ์ฃผ์‹œ๋ฉด ์ข‹๊ฒ ์Šต๋‹ˆ๋‹ค!๐Ÿ™†๐Ÿ’— + (์‚ฌ์ง„์„ ์ €์žฅํ•ด์„œ ์ด๋ฏธ์ง€ ์ž„๋ฒ ๋“œ๋ฅผ ํ•˜์…”๋„ ์ข‹๊ณ , ๋ณต์‚ฌ+๋ถ™์—ฌ๋„ฃ๊ธฐํ•ด์„œ ๋„ฃ์–ด์ฃผ์…”๋„ ์ข‹์Šต๋‹ˆ๋‹ค!) + +[]() + +# ๐ŸŽฏย ํ•ต์‹ฌ ํ‚ค์›Œ๋“œ + +--- + + + +### ํ‚ค์›Œ๋“œ ์ •๋ฆฌ ๐Ÿ  + +- Debounce & Throttling ๐Ÿ  + - Debounce๋Š” ๋ฌด์—‡์ผ๊นŒ์š”? + + ์ด๋ฒคํŠธ๊ฐ€ ๋ฐœ์ƒํ•  ๋•Œ, ์ธ์‹ํ•˜๋Š” ์ตœ์†Œ ์‹œ๊ฐ„์„ ์ง€์ •ํ•˜๋Š” ์ตœ์ ํ™” ๋ฐฉ์‹์ž…๋‹ˆ๋‹ค. + + ์˜ˆ๋ฅผ ๋“ค์–ด ์ด๋ฒคํŠธ๋ฅผ ์ธ์‹ํ•˜๊ฒŒํ•  ์ตœ์†Œ ์‹œ๊ฐ„์„ 10์ดˆ๋กœ ์ง€์ •ํ•˜๊ณ  + + 1์ดˆ ๊ฐ„๊ฒฉ์œผ๋กœ ๊ฐ™์€ ์ด๋ฒคํŠธ๋ฅผ ๊ณ„์† ๋ฐœ์ƒ์‹œํ‚ค๋ฉด, ์‹ค์ œ๋กœ ์ธ์‹๋˜์ง€ ์•Š๊ณ  + + 10์ดˆ ๊ฐ„๊ฒฉ ์ด์ƒ์œผ๋กœ ์‹คํ–‰๋˜๋Š” ์ด๋ฒคํŠธ๋งŒ์„ ์ธ์‹ํ•ฉ๋‹ˆ๋‹ค. + + - Debounce๋Š” ์ฃผ๋กœ ์–ด๋””์— ์‚ฌ์šฉํ•˜๋‚˜์š”? + + ์ด๋ฒคํŠธ๊ฐ€ ์—ฌ๋Ÿฌ๋ฒˆ ๋ฐœ์ƒํ•ด๋„, ํ•œ ๋ฒˆ๋งŒ ์‹คํ–‰๋˜๋Š” ๊ฒƒ์ด ์ •์ƒ์ ์ธ ๋กœ์ง์— ์‚ฌ์šฉํ•˜๋ฉด ๋ฉ๋‹ˆ๋‹ค. + + ์˜ˆ๋ฅผ ๋“ค์–ด ์‚ฌ์šฉ์ž๊ฐ€ ๋กœ๊ทธ์•„์›ƒ ๋ฒ„ํŠผ์„ ๋ˆ„๋ฅผ ๋•Œ, ์ •๋ง ๋น ๋ฅธ ์†๋„๋กœ 100๋ฒˆ ๋ฒ„ํŠผ์„ ํด๋ฆญํ•˜๋”๋ผ๋„, ์‹ค์ œ๋กœ ๋กœ๊ทธ์•„์›ƒ ํ•จ์ˆ˜๋ฅผ 100๋ฒˆ ํ˜ธ์ถœํ•˜๋Š” ๊ฒŒ ์•„๋‹ˆ๋ผ, ํ•œ ๋ฒˆ๋งŒ ์‹คํ–‰ํ•˜๋ฉด ๋˜๋Š” ๊ฒƒ์ด ์ •์ƒ์ ์ธ ๋กœ์ง์ธ ๊ฒฝ์šฐ์— ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค. + + - Throttling์€ ๋ฌด์—‡์ผ๊นŒ์š”? + + ์ด๋ฒคํŠธ ๋ฐœ์ƒ ์‚ฌ์ด์˜ ๋”œ๋ ˆ์ดํƒ€์ž„์„ ์ง€์ •ํ•˜๋Š” ๊ฒƒ์ž…๋‹ˆ๋‹ค. + + ์Šคํฌ๋กค ์ด๋ฒคํŠธ๋ฅผ ๊ตฌํ˜„ํ•  ๋•Œ, ์Šคํฌ๋กค์„ 0.1s์•ˆ์— ๋งค์šฐ ๊ธธ๊ฒŒ ๋งŽ์ด ํ•ด๋ฒ„๋ ธ์„๋•Œ, + + ์‚ฌ์šฉ์ž ์ž…๋ ฅ์— ๋งž์ถฐ ์ด๋ฒคํŠธ๋ฅผ ๋ฐœ์ƒ์‹œ์ผœ๋ฒ„๋ฆฌ๋ฉด, ๋ฌธ์ œ๊ฐ€ ์ƒ๊ธธ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. + + ์ด๋•Œ, ๊ทธ ์ด๋ฒคํŠธ๋“ค์„ ์ ๋‹นํ•œ ๊ฐ„๊ฒฉ์œผ๋กœ ์‹คํ–‰์‹œํ‚ค๋Š” ๊ฒ๋‹ˆ๋‹ค. + + - Throttling์€ ์ฃผ๋กœ ์–ด๋””์— ์‚ฌ์šฉํ•˜๋‚˜์š”? + + ์œ„์—์„œ ๋งํ•œ ๊ฒƒ ์ฒ˜๋Ÿผ, ์ ๋‹นํ•œ ๊ฐ„๊ฒฉ์œผ๋กœ ์‹คํ–‰์‹œ์ผœ์ฃผ๊ณ  ์‹ถ์€ ๋กœ์ง์— ์‚ฌ์šฉํ•˜๋ฉด ๋ฉ๋‹ˆ๋‹ค. + + - Debounce์™€ Throttling์˜ ์ฐจ์ด์ ์€ ๋ฌด์—‡์ผ๊นŒ์š”? + + ๋””๋ฐ”์šด์Šค๋Š” ๊ฒฐ๊ตญ ๋งˆ์ง€๋ง‰ ํ•˜๋‚˜์˜ ์ด๋ฒคํŠธ๋ฅผ ์‹คํ–‰ํ•˜๋Š” ๊ฒƒ์ด๊ณ , ์“ฐ๋กœํ‹€์€ ์—ฌ๋Ÿฌ๋ฒˆ ๋ฐœ์ƒํ•˜๋ฉด ๊ฐ„๊ฒฉ์„ ๋‘˜ ๋ฟ ์ „๋ถ€ ์ด๋ฒคํŠธ๊ฐ€ ์ž‘๋™ํ•ฉ๋‹ˆ๋‹ค. + + - ์–ด๋–ค ๊ธฐ๋Šฅ์„ ๊ตฌํ˜„ํ•  ๋•Œ Debounce๋ฅผ ์ ์šฉํ•˜๊ณ , Throttling์„ ์ ์šฉํ•˜๋Š” ๊ฒƒ์ด ์ข‹์„๊นŒ์š”? + + ์œ„์˜ ๋‚ด์šฉ๊ณผ ๊ฐ™์Šต๋‹ˆ๋‹ค. + +- ์ฟ ํ‚ค ๐Ÿ  + - ์ฟ ํ‚ค๋ž€ ๋ฌด์—‡์ด๊ณ , ์–ด๋–ค ํŠน์ง•์„ ๊ฐ€์ง€๊ณ  ์žˆ์„๊นŒ์š”? + + ์ฟ ํ‚ค๋Š” ๋กœ์ปฌ์Šคํ† ๋ฆฌ์ง€์™€ ๋งˆ์ฐฌ๊ฐ€์ง€๋กœ ํด๋ผ์ด์–ธํŠธ์ชฝ์— ๋ฐ์ดํ„ฐ๋ฅผ ์ €์žฅ์‹œํ‚ค๋Š” ๋ฐฉ์‹์ž…๋‹ˆ๋‹ค. + + ๋Œ€์‹  ์ฟ ํ‚ค๋Š” httpํ†ต์‹ ์— ์‚ฌ์šฉ๋˜๊ณ , session์„ ๋งŒ๋“ค๋•Œ๋„ ์ž๋™์œผ๋กœ ํ•˜๋‚˜ ์ƒ์„ฑ๋˜๊ณ , ๋” ์ž‘์€ ํฌ๊ธฐ ์ œํ•œ, ์œ ํšจ์‹œ๊ฐ„ ์„ค์ • ๋“ฑ๋“ฑ ์—ฌ๋Ÿฌ๊ฐ€์ง€ ๊ธฐ๋Šฅ์ด ์žˆ์Šต๋‹ˆ๋‹ค. httpOnly flag๋ฅผ ํ†ตํ•ด ๋ธŒ๋ผ์šฐ์ €์—์„œ์˜ ์ ‘๊ทผ์„ ๋ง‰์•„ ๋ณด์•ˆ์„ ๋†’์ผ ์ˆ˜๋„ ์žˆ์Šต๋‹ˆ๋‹ค. + + - ์ฟ ํ‚ค๋ฅผ ์–ด๋–ป๊ฒŒ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ์„๊นŒ์š”? + + ํŒจํ‚ค์ง€๋ฅผ ์‚ฌ์šฉํ•ด๋„ ๋˜๊ณ , document.cookie ์ฒ˜๋Ÿผ ์‚ฌ์šฉํ•ด๋„ ๋ฉ๋‹ˆ๋‹ค. + +- ํ† ํฐ ๐Ÿ  + - ํ† ํฐ์ด ์™œ ํ•„์š”ํ• ๊นŒ์š”? + + ์ธ์ฆ ๋ฐฉ์‹์˜ ์ผํ™˜์ž…๋‹ˆ๋‹ค, ์‚ฌ์šฉ์ž ์ •๋ณด ๊ฐ™์€ ์ค‘์š”ํ•œ ๋ฐ์ดํ„ฐ๋ฅผ ๊ทธ๋Œ€๋กœ ์ €์žฅํ•˜๊ณ  ์ „์†กํ•˜๋ฉด ์œ„ํ—˜์ด ํฌ๊ธฐ ๋•Œ๋ฌธ์— ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค. + + - CORS ์—๋Ÿฌ๊ฐ€ ๋ฌด์—‡์ด๊ณ , ์ด ์—๋Ÿฌ๋ฅผ ์–ด๋–ป๊ฒŒ ํ•ด๊ฒฐํ•  ์ˆ˜ ์žˆ์„๊นŒ์š”? + + ์ถœ์ฒ˜๊ฐ€ ๋‹ค๋ฅธ ์†Œ์Šค๋ฅผ ๊ต์ฐจํ•˜์—ฌ ์‚ฌ์šฉํ•˜์ง€ ๋ชปํ•˜๊ฒŒ ํ•˜๋Š” ์ •์ฑ…์„ ์–ด๊ธฐ๋ฉด ๋ฐœ์ƒํ•ฉ๋‹ˆ๋‹ค. + + proxy์„ค์ •์„ ๊ฑด๋“ ๋‹ค๊ฑฐ๋‚˜ ํ•˜๋Š” ๋ฐฉ์‹์œผ๋กœ ํ•ด๊ฒฐ์ด ๋˜์ง€๋งŒ, ์ผ๋‹จ + + CORS์—๋Ÿฌ๊ฐ€ ๋ฐœ์ƒํ•œ ์ •ํ™•ํ•œ ์›์ธ ๊ณ ๋ฏผํ•ด๋ด์•ผํ•ฉ๋‹ˆ๋‹ค. + + - JWT ํ† ํฐ ๊ธฐ๋ฐ˜ ์ธ์ฆ ๋ฐฉ๋ฒ•์ด๋ž€ ๋ฌด์—‡์ผ๊นŒ์š”? + + json ํ˜•์‹์œผ๋กœ ๋ฐ์ดํ„ฐ๋ฅผ ์•”ํ˜ธํ™”ํ•˜์—ฌ ์‚ฌ์šฉํ•˜๋Š” ๋ฐฉ์‹์ž…๋‹ˆ๋‹ค. + + - JWT ๊ธฐ๋ฐ˜ ๋กœ๊ทธ์ธ ๋™์ž‘ ๊ณผ์ •์— ๋Œ€ํ•ด ์•Œ์•„๋ณด์„ธ์š”. + + ์•”ํ˜ธํ™”๋œ ๋ฐ์ดํ„ฐ๋ฅผ ํ†ต์‹ ์— ์‚ฌ์šฉํ•˜๋ฉด ์„œ๋ฒ„์—์„œ, ๊ฒ€์ฆํ•˜๊ณ  ๋ฐ์ดํ„ฐ๋ฅผ ์ „๋‹ฌํ•ด์ค๋‹ˆ๋‹ค. + + - AccessToken / RefreshToken์˜ ์ฐจ์ด์— ๋Œ€ํ•ด ์„ค๋ช…ํ•ด์ฃผ์„ธ์š”. + + accessToken์˜ ์ฃผ๊ธฐ๋ฅผ ์งง๊ฒŒ Refresh๋Š” ๊ธธ๊ฒŒ ๊ฐ€์ ธ๊ฐ€์„œ, accessํ† ํฐ์€ ํƒˆ์ทจ์˜ ๋ฆฌ์Šคํฌ๋ฅผ ์ค„์ธ ๋’ค์— accessํ† ํฐ์„ ๋ฐ์ดํ„ฐ ํ†ต์‹ ์— ์ฃผ๋กœ ์‚ฌ์šฉํ•˜๊ณ  refresh๋Š” ๊ฐ€๋ ค๋‘ก๋‹ˆ๋‹ค. + +- ์›น ์Šคํ† ๋ฆฌ์ง€ ๐Ÿ  + - ์›น ์Šคํ† ๋ฆฌ์ง€์˜ ๋ฉ”์†Œ๋“œ์™€ ํ”„๋กœํผํ‹ฐ๋Š” ์–ด๋–ค๊ฒŒ ์žˆ์„๊นŒ์š”? + + get set key removeItem ๊ฐ™์€ ๋ฉ”์†Œ๋“œ๊ฐ€ ์žˆ๊ณ  + + length ํ”„๋กœํผํ‹ฐ ์žˆ์Šต๋‹ˆ๋‹ค. + + - ์„ธ์…˜ ์Šคํ† ๋ฆฌ์ง€์— ๋Œ€ํ•ด ์ •๋ฆฌํ•ด ์ฃผ์„ธ์š”! + + ํƒญ์„ ๊ธฐ์ค€์œผ๋กœ ์ €์žฅํ•˜๊ณ  ์‚ฌ์šฉํ•˜๋Š” ๋ฐ์ดํ„ฐ๊ฐ€ ๋“ค์–ด๊ฐ‘๋‹ˆ๋‹ค. + + - ๋กœ์ปฌ ์Šคํ† ๋ฆฌ์ง€์— ๋Œ€ํ•ด ์ •๋ฆฌํ•ด ์ฃผ์„ธ์š”! + - ๋ธŒ๋ผ์šฐ์ €์— ๋ฐ์ดํ„ฐ๋ฅผ **์˜๊ตฌ์ ์œผ๋กœ ์ €์žฅ**ํ•ฉ๋‹ˆ๋‹ค. + - ๋ช…์‹œ์ ์œผ๋กœ ์‚ญ์ œํ•˜์ง€ ์•Š๋Š” ์ด์ƒ ๋ธŒ๋ผ์šฐ์ €๋ฅผ ๋‹ซ์•„๋„ ๋ฐ์ดํ„ฐ๊ฐ€ ์œ ์ง€๋ฉ๋‹ˆ๋‹ค. + - ๋™์ผํ•œ ๋„๋ฉ”์ธ ๊ฐ„์— ๋ฐ์ดํ„ฐ๊ฐ€ ๊ณต์œ ๋ฉ๋‹ˆ๋‹ค + - ๋กœ์ปฌ ์Šคํ† ๋ฆฌ์ง€์—์„œ JWT ํ† ํฐ์„ ์ €์žฅํ•˜๊ณ , ์‚ฌ์šฉํ•˜๊ณ , ์‚ญ์ œํ•˜๋Š” ๋ฉ”์†Œ๋“œ์— ๋Œ€ํ•ด ์ฐพ์•„๋ณด์„ธ์š”! + + ์œ„์— ํ† ํฐ์—์„œ ์„ค๋ช…ํ•œ ๋ฐ”์™€ ๊ฐ™์Šต๋‹ˆ๋‹ค. ๋ง ๊ทธ๋Œ€๋กœ ์ €์žฅํ•˜๊ณ  ์‚ฌ์šฉํ•˜๊ณ  ์‚ญ์ œํ•  ๋ฟ์ด์ง€ JWT๋ผ๊ณ  ํ•ด์„œ ๋” ํŠน๋ณ„ํ•œ ๋ฌด์–ธ๊ฐ€๊ฐ€ ์žˆ๋Š” ๊ฒŒ ์•„๋‹™๋‹ˆ๋‹ค. + + ๋‹ค๋งŒ ํƒˆ์ทจ๋˜์—ˆ์„ ๋•Œ์˜ ๋ฌธ์ œ๋ฅผ ์ƒ๊ฐํ•ด์„œ ์—ฌ๋Ÿฌ๊ฐ€์ง€ ๋ณด์•ˆ ์žฅ์น˜๋ฅผ ๋งˆ๋ จํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค. + + ํ”„๋ก ํŠธ์—์„œ ๋‹ค๋ฃจ๋Š” ๋ฐ์ดํ„ฐ๋Š” ๋ฌด์กฐ๊ฑด ํƒˆ์ทจ๊ฐ€๋Šฅํ•ฉ๋‹ˆ๋‹ค. ํƒˆ์ทจ๋ฅผ ์ตœ๋Œ€ํ•œ ๋ฐฉ์ง€ํ•˜๋Š” ๋ฐฉ์‹์œผ๋กœ ์„ค๊ณ„ํ•˜๋˜, ๋ฐ˜๋“œ์‹œ ํƒˆ์ทจ๊ฐ€ ๋˜์—ˆ๋‹ค๋Š” ๊ฒฝ์šฐ๋„ ๊ฐ€์ •ํ•ด์•ผํ•ฉ๋‹ˆ๋‹ค. ์ด๋ถ€๋ถ„์€ ๋ฐฑ์—”๋“œ์—์„œ ๋” ๋งŽ์ด ๊ณ ๋ฏผํ•ด์•ผํ•  ๋ฌธ์ œ์ด๊ธฐ๋„ ํ•ฉ๋‹ˆ๋‹ค. + + - ์Šคํ† ๋ฆฌ์ง€๊ฐ€ ๋ณ€๊ฒฝ๋˜์—ˆ์„ ๋•Œ ์ฒ˜๋ฆฌํ•˜๋Š” ๋ฐฉ๋ฒ•์„ ์กฐ์‚ฌํ•ด ์ฃผ์„ธ์š”. + + + ์Šคํ† ๋ฆฌ์ง€ ๋ณ€๊ฒฝ์€ `storage` ์ด๋ฒคํŠธ๋กœ ์ฒ˜๋ฆฌํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ์ด ์ด๋ฒคํŠธ๋Š” **๋‹ค๋ฅธ ๋ธŒ๋ผ์šฐ์ € ํƒญ์ด๋‚˜ ์ฐฝ์—์„œ ์Šคํ† ๋ฆฌ์ง€ ๋ฐ์ดํ„ฐ๊ฐ€ ๋ณ€๊ฒฝ๋  ๋•Œ ๋ฐœ์ƒ**ํ•ฉ๋‹ˆ๋‹ค. + + - Bearer Token์ด ๋ฌด์—‡์ธ์ง€ ์ฐพ์•„๋ณด๊ณ , ์ด๋ฅผ ํ†ตํ•ด ๋ฐฑ์—”๋“œ ์„œ๋ฒ„์™€ ์–ด๋– ํ•œ ๋ฐฉ์‹์œผ๋กœ ํ†ต์‹ ํ•˜๋Š”์ง€ ์กฐ์‚ฌํ•ด ๋ณด์„ธ์š”! + - ์ธ์ฆ ์ •๋ณด๋ฅผ ํฌํ•จํ•œ ๋ฌธ์ž์—ด ํ˜•ํƒœ์˜ ํ† ํฐ์œผ๋กœ, ์ฃผ๋กœ **OAuth 2.0**์—์„œ ์‚ฌ์šฉ๋ฉ๋‹ˆ๋‹ค. + - ํด๋ผ์ด์–ธํŠธ๊ฐ€ ์„œ๋ฒ„๋กœ ์š”์ฒญ์„ ๋ณด๋‚ผ ๋•Œ **HTTP ํ—ค๋”์˜ `Authorization` ํ•„๋“œ์— ํฌํ•จ**ํ•˜์—ฌ ์ „์†ก. +- Context-API ๐Ÿ  + - ์ „์—ญ ์ƒํƒœ ๊ด€๋ฆฌ๋Š” ์™œ ํ•ด์•ผํ• ๊นŒ์š”? + + ์œ ์ง€๋ณด์ˆ˜์™€, ์ตœ์ ํ™” ๋•Œ๋ฌธ์— ํ•„์š”ํ•ฉ๋‹ˆ๋‹ค. + + - Context API๋ž€ ๋ฌด์—‡์ผ๊นŒ์š”? + + ๋ฐ์ดํ„ฐ๋ฅผ ์—ฌ๋Ÿฌ ์ปดํฌ๋„ŒํŠธ์—์„œ ์‚ฌ์šฉํ•˜๊ณ ์ž ํ•  ๋•Œ, ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค + + ํ•˜์ง€๋งŒ, ์žฌ์‚ฌ์šฉ ์„ฑ์„ ๋‚ฎ์ถ”๊ณ , ์ƒํƒœ๊ฐ€ ์ˆ˜์ •๋  ๋•Œ ๋ชจ๋“  ํ•˜์œ„ ์ปดํฌ๋„ŒํŠธ๊ฐ€ ์žฌ ๋ Œ๋”๋ง ๋˜๋Š” ๊ฑด ๋งˆ์ฐฌ๊ฐ€์ง€๊ธฐ ๋•Œ๋ฌธ์— ๋‹จ์ˆœํžˆ props drilling์„ ํ•ด๊ฒฐํ•˜๊ธฐ ์œ„ํ•ด์„œ๋งŒ ์‚ฌ์šฉํ•˜๊ธฐ์—” ์ ์ ˆํ•˜์ง„ ์•Š์Šต๋‹ˆ๋‹ค. + + + + +https://www.youtube.com/watch?v=WQHuqL2S74o&t=877s + +https://www.youtube.com/watch?v=WQHuqL2S74o&t=877s + +# โœ…ย ์‹ค์Šต + +- [x] ๊ธฐ์กด 2์ฃผ์ฐจ `React`๋กœ ์ œ์ž‘ํ•œ **`ToDoList`**๋ฅผ, **`Context-API`**๋ฅผ ํ™œ์šฉํ•˜์—ฌ **`๋ฆฌํŒฉํ† ๋ง์„ ์ง„ํ–‰`**ํ•ด์ฃผ์„ธ์š”! + + todoList๋ฅผ ์–ด๋–ป๊ฒŒ ๊ตฌํ˜„ํ–ˆ๋Š” ์ง€๋Š” ๋ชฐ๋ผ๋„, ์ €๋Š” ์ „์—ญ์ƒํƒœ ๊ด€๋ฆฌ๋ฅผ ์ถ”๊ฐ€ํ•ด์„œ ๋ฆฌํŒฉํ† ๋ง ํ•  ๋ถ€๋ถ„์€ ์—†์—ˆ์Šต๋‹ˆ๋‹ค. + + ๊ทธ๋ž˜๋„ ๊ทธ๋ƒฅ ํ•˜๋Š” ๊น€์— recoil๋กœ ํ•ด๋ดค์Šต๋‹ˆ๋‹ค. + + contextAPI๋‚˜ recoil์ด๋‚˜ ์‚ฌ์šฉ๋ฐฉ๋ฒ•์€ ๊ฑฐ์˜ ๋˜‘๊ฐ™์Šต๋‹ˆ๋‹ค. ์ž‘๋™ ๊ตฌ์กฐ๊ฐ€ ๋‹ค๋ฅผ ๋ฟ์ด๊ณ  ์‚ฌ์šฉ ๋ฐฉ๋ฒ•, ๋ชฉ์ ์— ํฐ ์ฐจ์ด๊ฐ€ ์žˆ์ง„ ์•Š์Šต๋‹ˆ๋‹ค. + + ๊ทธ๋ฆฌ๊ณ  ์ผ๋ฐ˜์ ์œผ๋กœ useState๋ฅผ ํ†ตํ•ด ๋งŒ๋“  state๋Š” ์ง์ ‘ ์ˆ˜์ •์€ ์•ˆ๋˜์ง€๋งŒ, ๊ฐ„์ ‘ ์ ‘๊ทผ์„ ํ†ตํ•œ ์ˆ˜์ •์ด ๋ฉ๋‹ˆ๋‹ค. + + ์˜ˆ๋ฅผ ๋“ค์–ด ์—ฌ๊ธฐ์„ , todoList ์•ˆ์— ๊ฐ์ฒด์˜ ๋ฐฐ์—ด์„ ๊ฐ€์ง€๊ณ  ์žˆ๋Š”๋ฐ, copyList = todoList; + + copyList[index].member = โ€œchangedโ€; ๋กœ ์ˆ˜์ •์ด ๊ฐ€๋Šฅํ•ฉ๋‹ˆ๋‹ค. + + recoil์€ ์ด๋Ÿฐ ๋ถ€๋ถ„๋“ค์„ ๋ฐฉ์ง€ํ•ด์„œ, state๊ด€๋ฆฌ๋ฅผ ๋” ํŽธํ•˜๊ณ  ์—„๊ฒฉํ•˜๊ฒŒ ํ•ด์ค๋‹ˆ๋‹ค + +- ๊นƒํ—ˆ๋ธŒ ์ฃผ์†Œ + + https://github.com/RyuDongHo/UmcWeb + +- ์‹คํ–‰ ์˜์ƒ + + [20241113-1623-08.7413001.mp4](https://prod-files-secure.s3.us-west-2.amazonaws.com/f1912130-0409-4e90-a90f-6091ae253e73/55f199b5-d199-4479-91f9-aa6153651b23/20241113-1623-08.7413001.mp4) + + +# ๐Ÿ”ฅย ๋ฏธ์…˜ 1. ํšŒ์›๊ฐ€์ž… / ๋กœ๊ทธ์ธ API ์—ฐ๊ฒฐ + + + +https://github.com/dydals3440/UMC-7th-YONGCHA-BE + +### 1. ํšŒ์›๊ฐ€์ž… + +![แ„‰แ…ณแ„แ…ณแ„…แ…ตแ†ซแ„‰แ…ฃแ†บ 2024-09-30 แ„‹แ…ฉแ„Œแ…ฅแ†ซ 12.17.05.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/f1912130-0409-4e90-a90f-6091ae253e73/78d333fa-aa22-492f-828f-335b3927525d/%E1%84%89%E1%85%B3%E1%84%8F%E1%85%B3%E1%84%85%E1%85%B5%E1%86%AB%E1%84%89%E1%85%A3%E1%86%BA_2024-09-30_%E1%84%8B%E1%85%A9%E1%84%8C%E1%85%A5%E1%86%AB_12.17.05.png) + +- [x] **`ํšŒ์›๊ฐ€์ž… API`**๋ฅผ ์ž˜ ์—ฐ๊ฒฐํ•˜์˜€๋Š”๊ฐ€? +- [x] ํšŒ์›๊ฐ€์ž… ํ›„, `login ํŽ˜์ด์ง€`๋กœ ์ด๋™ํ•˜์˜€๋Š”๊ฐ€? + +### 2. ๋กœ๊ทธ์ธ + +![แ„‰แ…ณแ„แ…ณแ„…แ…ตแ†ซแ„‰แ…ฃแ†บ 2024-09-30 แ„‹แ…ฉแ„Œแ…ฅแ†ซ 12.18.19.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/f1912130-0409-4e90-a90f-6091ae253e73/12e13eac-1a6d-4ea4-8688-970d2283b60f/%E1%84%89%E1%85%B3%E1%84%8F%E1%85%B3%E1%84%85%E1%85%B5%E1%86%AB%E1%84%89%E1%85%A3%E1%86%BA_2024-09-30_%E1%84%8B%E1%85%A9%E1%84%8C%E1%85%A5%E1%86%AB_12.18.19.png) + +- [x] **`๋กœ๊ทธ์ธ API`**๋ฅผ ์ž˜ ์—ฐ๊ฒฐํ•˜์˜€๋Š”๊ฐ€? +- [x] ๋กœ๊ทธ์ธ ํ›„, `๋ฉ”์ธ ํŽ˜์ด์ง€`๋กœ ์ด๋™ํ•˜์˜€๋Š”๊ฐ€? +- [x] **`AccessToken`**๊ณผ, **`RefreshToken`**์„ **`๋กœ์ปฌ์Šคํ† ๋ฆฌ์ง€์—์„œ ์ €์žฅ`**ํ•˜์˜€๋Š”๊ฐ€? + +### 3. ๋กœ๊ทธ์ธ ํ›„ ๋ฉ”์ธ ํŽ˜์ด์ง€ ์ด๋™ ์‹œ + +![แ„‰แ…ณแ„แ…ณแ„…แ…ตแ†ซแ„‰แ…ฃแ†บ 2024-09-30 แ„‹แ…ฉแ„Œแ…ฅแ†ซ 12.14.44.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/f1912130-0409-4e90-a90f-6091ae253e73/b095f639-230d-4bb4-9fc4-69cee14ada08/%E1%84%89%E1%85%B3%E1%84%8F%E1%85%B3%E1%84%85%E1%85%B5%E1%86%AB%E1%84%89%E1%85%A3%E1%86%BA_2024-09-30_%E1%84%8B%E1%85%A9%E1%84%8C%E1%85%A5%E1%86%AB_12.14.44.png) + +- [x] **`Navbar`**์˜ ๋กœ๊ทธ์ธ, ํšŒ์›๊ฐ€์ž… ๋ฒ„ํŠผ ๋Œ€์‹ , **`๋กœ๊ทธ์•„์›ƒ ๋ฒ„ํŠผ`**์„ ๋ณด์—ฌ์ฃผ์—ˆ๋Š”๊ฐ€? +- [x] **`์œ ์ € ์ •๋ณด ๋ถˆ๋Ÿฌ์˜ค๊ธฐ API`**๋ฅผ ํ˜ธ์ถœํ•˜์—ฌ, ๋กœ๊ทธ์ธ ํ•œ ์œ ์ € ์ด๋ฉ”์ผ **`@ ๊ธฐ์ค€ ์•ž ๋ถ€๋ถ„(๋‹‰๋„ค์ž„)`**์„ Navbar์— ์ž˜ ๋ณด์—ฌ์ฃผ์—ˆ๋Š”๊ฐ€? + +### 4. ๋กœ๊ทธ์•„์›ƒ ์‹œ + +![แ„‰แ…ณแ„แ…ณแ„…แ…ตแ†ซแ„‰แ…ฃแ†บ 2024-09-30 แ„‹แ…ฉแ„Œแ…ฅแ†ซ 12.21.38.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/f1912130-0409-4e90-a90f-6091ae253e73/219d8a2b-3eac-4149-a144-c36676387d4f/%E1%84%89%E1%85%B3%E1%84%8F%E1%85%B3%E1%84%85%E1%85%B5%E1%86%AB%E1%84%89%E1%85%A3%E1%86%BA_2024-09-30_%E1%84%8B%E1%85%A9%E1%84%8C%E1%85%A5%E1%86%AB_12.21.38.png) + +- [x] ๋กœ๊ทธ์•„์›ƒ ํ›„, Navbar์— ์œ ์ € ์ •๋ณด๊ฐ€, ์‚ฌ๋ผ์ง€๋ฉฐ, **`๋กœ๊ทธ์ธ, ํšŒ์›๊ฐ€์ž… ๋ฒ„ํŠผ์ด ๋‹ค์‹œ ์ƒ๊ฒผ๋Š”๊ฐ€?`** +- [x] **`AccessToken`**๊ณผ, **`RefreshToken`**์„ **`๋กœ์ปฌ์Šคํ† ๋ฆฌ์ง€์—์„œ ์ œ๊ฑฐ`**ํ•˜์˜€๋Š”๊ฐ€? + +### 5. ์ถ”๊ฐ€๋กœ ํ•ด๋ณด๋ฉด ์ข‹์•„์š”! + +- [x] `refreshToken์„ ํ™œ์šฉ`**ํ•˜์—ฌ,** `ํ† ํฐ ์žฌ๋ฐœ๊ธ‰`**์„ ์ง„ํ–‰ํ•ด๋ณด์„ธ์š”.** + - [x] **`Axios Interceptor`**๋ฅผ ํ™œ์šฉํ•˜์—ฌ, **`refreshToken`**์„ ํ™œ์šฉํ•˜์—ฌ, **`accessToken`**์„ **`์žฌ๋ฐœ๊ธ‰`** ๋ฐ›๋Š” ๋กœ์ง์„ ๊ตฌ๊ธ€ ๊ฒ€์ƒ‰์„ ํ†ตํ•ด, ์ง์ ‘ ํ•ด๊ฒฐํ•ด๋ณด์„ธ์š”! + + axios๋Š” ์“ฐ์ง€ ์•Š๊ณ  fetch๋กœ ํ•˜๋“œ์ฝ”๋”ฉ ํ•ด๋ดค์Šต๋‹ˆ๋‹ค. + + axios๋งŒ ์“ธ ๋•Œ๋Š”, ๊ทธ๋ƒฅ ๊ธฐ๋Šฅ์ด ํŽธํ•˜๋‹ˆ๊นŒ ์“ด๋‹ค ๊ณ ๋งŒ ์ƒ๊ฐํ–ˆ์ง€ ๊ตฌ์ฒด์ ์œผ๋กœ ์–ด๋–ค ์ด์œ ๋กœ ์“ฐ๋Š” ์ง€ ๊ฐ์ด ์•ˆ ์™”๋Š”๋ฐ, + + fetch๋กœ ํ•˜๋‚˜์”ฉ ์„ค๊ณ„ํ•ด๋ณด๋‹ˆ, ํด๋” ๊ตฌ์กฐ์— ๋งž๊ฒŒ ์‘์ง‘๋„ ๋†’์€ ๊ตฌ์กฐ๋ฅผ ์„ค๊ณ„ํ•˜๋ ค๋ฉด, ์‹ ๊ฒฝ ์“ธ ๋ถ€๋ถ„์ด ์ƒ๊ฐ๋ณด๋‹ค ๋งŽ์•˜์Šต๋‹ˆ๋‹ค. + + - [x] **`refreshToken`**์„ ํ™œ์šฉํ•˜์—ฌ, ํ† ํฐ ์žฌ๋ฐœ๊ธ‰์„ ์ง„ํ–‰ํ•˜๋ฉด, ์–ด๋–ค ๋ถ€๋ถ„์—์„œ ์ด์ ์ด ์žˆ๋Š”์ง€ ์ž‘์„ฑํ•ด์ฃผ์„ธ์š”! + - ์–ด๋–ค ์žฅ์ ์ด ์žˆ์„๊นŒ์š”? + + accessToken์˜ ์œ ํšจ๊ธฐ๊ฐ„์„ ์งง๊ฒŒ ํ•จ์œผ๋กœ์„œ accessToken์ด ํƒˆ์ทจ๋˜์–ด๋„ ๋ณด์•ˆ์ƒ์˜ ์œ„ํ˜‘์„ ๋‚ฎ์ถ”๊ธฐ ์œ„ํ•จ์ž…๋‹ˆ๋‹ค. + + ์ฆ‰ accessToken์ด refreshToken๊ณผ ๋‹ค๋ฅธ ๋ฐฉ์‹์œผ๋กœ ์ €์žฅ๋˜์–ด, ์‚ฌ์šฉ์ž๊ฐ€ refreshToken์— ์ ‘๊ทผํ•˜์ง€ ๋ชปํ•˜๋„๋ก ๋ฐฉ์ง€ํ•ด์•ผ ์ด ๋ฐฉ๋ฒ•์ด ์˜๋ฏธ๊ฐ€ ์žˆ์Šต๋‹ˆ๋‹ค. + + ๊ทธ๋ž˜์„œ ์ €๋Š” accessToken์€ ์ฟ ํ‚ค์— ์ €์žฅํ•˜๊ณ  refreshToken ์€ httpOnly์˜ต์…˜์„ ์ฃผ๊ณ  ์ฟ ํ‚ค์— ์ €์žฅํ•˜๋Š” ๋ฐฉ์‹์„ ๊ตฌํ˜„ํ–ˆ์œผ๋‚˜, ๋ฐฑ์—”๋“œ์—์„œ httpOnlyํ˜•์‹์˜ ์ฟ ํ‚ค๋ฅผ ์ง์ ‘ ๋ถ„์„ํ•ด์„œ ์‚ฌ์šฉํ•˜๋Š” ๋ฐฉ์‹์„ ๊ตฌํ˜„ํ•ด์ฃผ์–ด์•ผ ํ•˜๊ธฐ ๋•Œ๋ฌธ์—, ๊ณผ์ œ์—์„  httpOnly๋ฐฉ์‹์„ ๊ตฌํ˜„๋งŒ ํ•ด๋‘๊ณ  ์ผ๋‹จ accessToken๊ณผ ๊ฐ™์€ ๋ฐฉ์‹์œผ๋กœ ์ €์žฅํ•˜๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค. + + +### ๐Ÿ”ฅย ๋ฏธ์…˜ 1. ์ œ์ถœ + +- ๊นƒํ—ˆ๋ธŒ ์ฃผ์†Œ + + https://github.com/RyuDongHo/UmcWeb + +- ์‹คํ–‰ ์˜์ƒ + + ์•„๋ž˜์— ํ•œ๋ฒˆ์— ์˜ฌ๋ฆฌ๊ฒ ์Šต๋‹ˆ๋‹ค + + +# ๐Ÿ”ฅย ๋ฏธ์…˜ 2. QueryParameter ํ™œ์šฉ ๊ฒ€์ƒ‰ ๊ธฐ๋Šฅ ๊ตฌํ˜„ + + + +- [x] **`Styled-Components`**๋ฅผ ํ™œ์šฉํ•ด์ฃผ์„ธ์š” +- [x] ๊ธฐ์กด์— ๋งŒ๋“ค์—ˆ๋˜, **`movie-card ์ปดํฌ๋„ŒํŠธ`**๋ฅผ ์žฌ์‚ฌ์šฉํ•ด์ฃผ์„ธ์š”. + +1. ์˜ํ™” ์ œ๋ชฉ ๊ฒ€์ƒ‰์–ด๋ฅผ ์ž…๋ ฅํ•˜์ง€ ์•Š๋Š” ๊ฒฝ์šฐ (`/search` ๊ฒฝ๋กœ์— ์ฒ˜์Œ ์˜จ ๊ฒฝ์šฐ) + + ![แ„‰แ…ณแ„แ…ณแ„…แ…ตแ†ซแ„‰แ…ฃแ†บ 2024-09-25 แ„‹แ…ฉแ„’แ…ฎ 8.39.03.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/f1912130-0409-4e90-a90f-6091ae253e73/b4deb1da-f975-4254-8e2c-629fead9ec2b/%E1%84%89%E1%85%B3%E1%84%8F%E1%85%B3%E1%84%85%E1%85%B5%E1%86%AB%E1%84%89%E1%85%A3%E1%86%BA_2024-09-25_%E1%84%8B%E1%85%A9%E1%84%92%E1%85%AE_8.39.03.png) + + +1. ์˜ํ™” ์ œ๋ชฉ ๊ฒ€์ƒ‰์–ด๋ฅผ ์ž…๋ ฅํ•œ ๊ฒฝ์šฐ + + ![แ„‰แ…ณแ„แ…ณแ„…แ…ตแ†ซแ„‰แ…ฃแ†บ 2024-09-25 แ„‹แ…ฉแ„’แ…ฎ 8.40.23.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/f1912130-0409-4e90-a90f-6091ae253e73/53f552ef-5ecf-451f-95c3-6c0ce839ab3e/%E1%84%89%E1%85%B3%E1%84%8F%E1%85%B3%E1%84%85%E1%85%B5%E1%86%AB%E1%84%89%E1%85%A3%E1%86%BA_2024-09-25_%E1%84%8B%E1%85%A9%E1%84%92%E1%85%AE_8.40.23.png) + + +1. ์˜ํ™” ๊ฒ€์ƒ‰์–ด๋ฅผ ์ž…๋ ฅํ–ˆ์œผ๋‚˜, ํ•ด๋‹น ๊ฒ€์ƒ‰์–ด์˜ ์˜ํ™” ๋ฐ์ดํ„ฐ๊ฐ€ ์กด์žฌํ•˜์ง€ ์•Š๋Š” ๊ฒฝ์šฐ. + + ![แ„‰แ…ณแ„แ…ณแ„…แ…ตแ†ซแ„‰แ…ฃแ†บ 2024-09-25 แ„‹แ…ฉแ„’แ…ฎ 8.48.41.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/f1912130-0409-4e90-a90f-6091ae253e73/5f4401e5-85aa-4ea3-999f-35982279b4a6/%E1%84%89%E1%85%B3%E1%84%8F%E1%85%B3%E1%84%85%E1%85%B5%E1%86%AB%E1%84%89%E1%85%A3%E1%86%BA_2024-09-25_%E1%84%8B%E1%85%A9%E1%84%92%E1%85%AE_8.48.41.png) + + +1. ๋กœ๋”ฉ ์ค‘์ธ ๊ฒฝ์šฐ, ์•„๋ž˜์™€ ๊ฐ™์€ **`Skeleton UI`**๋ฅผ ๋งŒ๋“ค์–ด์ฃผ์„ธ์š”! + +[แ„’แ…ชแ„†แ…งแ†ซ แ„€แ…ตแ„…แ…ฉแ†จ 2024-09-25 แ„‹แ…ฉแ„’แ…ฎ 9.49.33.mov](https://prod-files-secure.s3.us-west-2.amazonaws.com/f1912130-0409-4e90-a90f-6091ae253e73/acd1e244-c55b-48ea-b5dc-d3df7f22c7e8/%E1%84%92%E1%85%AA%E1%84%86%E1%85%A7%E1%86%AB_%E1%84%80%E1%85%B5%E1%84%85%E1%85%A9%E1%86%A8_2024-09-25_%E1%84%8B%E1%85%A9%E1%84%92%E1%85%AE_9.49.33.mov) + +1. **`Debounce`**์— ๋Œ€ํ•œ ํ‚ค์›Œ๋“œ๋ฅผ ํ•™์Šตํ•˜์…จ๋‚˜์š”? + - [x] **`Debounce`** ๊ฐ€ ๋ฌด์—‡์ธ์ง€ ์ž‘์„ฑํ•ด์ฃผ์„ธ์š”~! + - Debounce๋Š” ๋ฌด์—‡์ธ๊ฐ€์š”? + + Debounce๋Š” ํ•จ์ˆ˜๊ฐ€ ์—ฐ์†์ ์œผ๋กœ ์—ฌ๋Ÿฌ๋ฒˆ ํ˜ธ์ถœ๋˜๋ฉด, ํ˜ธ์ถœ๋  ๋•Œ๋งˆ๋‹ค ํ•จ์ˆ˜๋ฅผ ํ˜ธ์ถœํ•˜๋Š” ๊ฒŒ ์•„๋‹ˆ๋ผ, ๋งˆ์ง€๋ง‰ ํ•จ์ˆ˜ ํ˜ธ์ถœ ์‹œ์ ์œผ๋กœ๋ถ€ํ„ฐ ์ง€์ •ํ•œ ์‹œ๊ฐ„์ด ์ง€๋‚˜๋ฉด ๊ทธ๋•Œ ํ•จ์ˆ˜๋ฅผ ํ˜ธ์ถœํ•˜๋Š” ์ตœ์ ํ™” ๋ฐฉ์‹. + + - [ ] Debounce๋ฅผ ๊ฒ€์ƒ‰ ๊ธฐ๋Šฅ์— ์ ์šฉํ•ด์ฃผ์„ธ์š”! + + ๊ฒ€์ƒ‰์–ด๊ฐ€ ๋ณ€ํ•  ๋•Œ๋งŒ apiํ†ต์‹ ์ด ๋ฐœ์ƒํ•˜๋„๋ก ๋กœ์ง์„ ๊ตฌ์„ฑํ–ˆ๊ธฐ ๋•Œ๋ฌธ์— + + debounce๋ฅผ ์ ์šฉํ• ๋งŒํ•œ ๊ณณ์ด ์—†์–ด์„œ ์ปค์Šคํ…€ํ›…์œผ๋กœ ๋งŒ๋“ค์–ด๋งŒ ๋‘๊ณ  ์ ์šฉํ•˜์ง„ ์•Š์•˜์Šต๋‹ˆ๋‹ค. + + - ์‹คํ–‰ ์˜์ƒ ์ฒจ๋ถ€ + +- [ ] ํ˜น์‹œ๋ผ๋„, ๊ตฌํ˜„์— ์–ด๋ ค์›€์„ ๋Š๋ผ์‹  ๊ฒฝ์šฐ, ์•„๋ž˜ ์˜์ƒ์„ ์ฐธ๊ณ ํ•ด์„œ, ๋ฏธ์…˜์„ ์ˆ˜ํ–‰ํ•ด์ฃผ์„ธ์š”. + +https://www.youtube.com/watch?v=L3eGGsAyd_A + +### ๐Ÿ”ฅย ๋ฏธ์…˜ 2. ์ œ์ถœ + +- ๊นƒํ—ˆ๋ธŒ ์ฃผ์†Œ + + https://github.com/RyuDongHo/UmcWeb + +- ์‹คํ–‰ ์˜์ƒ + + [qwe.mp4](https://prod-files-secure.s3.us-west-2.amazonaws.com/f1912130-0409-4e90-a90f-6091ae253e73/cd6cf180-4ed4-44cd-b5dc-8fa19e58ad01/qwe.mp4) + + +# โšก ํŠธ๋Ÿฌ๋ธ” ์ŠˆํŒ… \ No newline at end of file