๋ฆฌ์กํธ ํ ์ค์ ๋ํด์ ์์๋ณด์.
Log ๐
- 21.12 Restart and Reset all-
22.01.03 Finish MiniProject03
-
23.02.01 ๋ฆฌ์กํธํ ์ค101 ํ์ด์งํ!
์์ ์ ๋ฆฌ์กํธ์์๋ ์ํ ๋ณํ
์ ๊ด๋ฆฌํ๊ธฐ ์ํด, ํน์ API์์ฒญ
์ ํ์๋ก ํ ๋, ๋ฆฌ์กํธ์ ๋ผ์ดํ ๋ผ์ดํด ๋ฉ์๋๋ฅผ ์ด์ฉํ๋ ์ํฉ์์๋ ํญ์ class๊ธฐ๋ฐ
์ผ๋ก ๊ตฌํํด์ผ๋ง ํ๋ค. ๊ทธ๋ ๊ธฐ ๋๋ฌธ์ ํจ์ํ ์ปดํผ๋ํธ๋ ๋จ์ํ props๋ฅผ ๊ฑด๋ค์ฃผ๋ ์ญํ ์ ํตํด์ ๋จ์ presenter์ ์ญํ ์ ์ปดํผ๋ํธ๋ก์ ์ฌ์ฉ๋์๋ค.
์ด๋ฌํ ํจ์ํ ์ปดํผ๋ํธ๊ฐ ๊ฐ๋ ๋ฌธ์ ์ ์ ํด๊ฒฐํ๊ธฐ ์ํด์, ํจ์ํ์ ์ข ๋ ๋ฐ์ ์ํค๊ธฐ ์ํด์ recompose ๋ผ๋ ํ๋ก์ ํธ๊ฐ Andrew Clark
์ ์ํด์ ์งํ๋์๋ค. ์ด ํ๋ก์ ํธ๊ฐ ์ข์ ๋ฐ์์ ์ป์ผ๋ฉด์ ์ ์ฐจ์ ์ผ๋ก ํจ์ํ ๋ฆฌ์กํธ์ ๋ํ ์๊ตฌ๊ฐ ๋ง์์ก๊ณ , ์ค์ ๋ก ํ์ด์ค๋ถ ๋ด๋ถ์ ์ผ๋ก ํจ์ํ ๋ฆฌ์กํธ(ํ
์ค)๋ฅผ ๊ฐ๋ฐ ์ค์ ์์๋ค๊ณ ํ๋ค. ๊ฒฐ๊ณผ์ ์ผ๋ก Andrew๋ React Team์ ํฉ๋ฅํ๊ฒ ๋๊ณ , ์ด ํ๋ก์ ํธ๋ฅผ ์ ๊ฒฉ์ ์ผ๋ก ๋ฆฌ์กํธ๊ฐ ๋ฐ์๋ค์ฌ์ React Hooks
๊ฐ ํ์(?)ํ์๋ค. React Hooks
์ ๋ฆฌ์กํธ๋ฅผ ํจ์ํ ์ปดํผ๋ํธ์์๋ ํด๋์ค ์ปดํผ๋ํธ์ ๋์ผํ๊ฒ ์๋ํ๊ฒ๋ ๊ตฌํํ๊ณ ์ ํ๋ ๋๊ธฐ๋ฅผ ๊ฐ๊ณ ํ์ํ๊ฒ ๋ ๋ฆฌ์กํธ์ ์
๋ฐ์ดํธ ๋ฒ์ ์ด๋ผ๊ณ ํ ์ ์๋ค.
ํ ์ค๋ ์๋ค๋ฅธ ๊ฐ๋ ์ด ์๋๋ค. ๊ธฐ์กด์ ํจ์ํ ์ปดํผ๋ํธ์ ์ฝ๊ฐ์ ๊ธฐ๋ฅ(?)์ด ์ถ๊ฐ๋ ๊ฐ๋ ์ด๋ค. ์ฆ ์๋ฐ์คํฌ๋ฆฝํธ ํจ์์ ๊ฐ๋ ์ ์ผ๋ก ๊ฐ๋ค. ์ฌ๊ธฐ์ ์์๋์ด์ผ ํ ํ ์ค์ 2๊ฐ์ง ๊ท์น์ด ์๋ค.
-
ํญ์ ์ต์์(at the Top Level)์์๋ง Hook์ ํธ์ถํด์ผ ํ๋ค. ๋ฐ๋ณต๋ฌธ, ์กฐ๊ฑด๋ฌธ ํน์ ์ค์ฒฉ๋ ํจ์ ๋ด์์ Hook์ ํธ์ถํ๊ฒ ๋๋ฉด ์๋ฌ๊ฐ ๋ฐ์ํ๋ค.
-
์ค์ง React ํจ์ ๋ด์์ Hook์ ํธ์ถํด์ผ ํ๋ค. ์ผ๋ฐ์ ์ธ ์๋ฐ์คํฌ๋ฆฝํธ ํจ์ ๋ด์์๋ ํธ์ถํ๋ฉด ์๋๋ค. ๋จ, ์ปค์คํ ํ ์ค ์์์๋ ๋ค๋ฅธ ํ ์ค๋ฅผ ํธ์ถํ ์ ์๋ค.
ํ ์ค๊ฐ ๋ด๋ถ์ ์ผ๋ก ์ด๋ป๊ฒ ์๋ํ ๊น?
https://hewonjeong.github.io/deep-dive-how-do-react-hooks-really-work-ko/
https://jeonghwan-kim.github.io/dev/2022/04/11/use-state.html
https://www.the-guild.dev/blog/react-hooks-system
https://ko.reactjs.org/docs/hooks-intro.html
๋ฆฌ์กํธ์ ์ ๊ณตํ๋ Hooks API๋ ์ด 10๊ฐ์ง๊ฐ ์กด์ฌํ๋ค. ๊ฐ๊ฐ์ API๊ฐ ์ด๋ป๊ฒ ๋์ํ๊ณ ์ด๋ป๊ฒ ์ฌ์ฉํด์ผํ๋์ง ์์๋ณด์.
๐ Hook List
-
useReducer
-
useCallback
-
useMemo
-
useImperativeHandle
-
useLayoutEffect
-
useDebugValue
-
Lotto Game โ
lotto-game
directory -
TicTacToe
tictactoe
directoryuseReducer์ Context API๋ฅผ ํ์ฉํด๋ณด์.
-
Context Dashboard โ
dashboard
directoryContext API ํ์ฉํ๋ ๊ฐ๋จํ ToDo-Dashboard
-
Mine Sweeper
Hooks์ ์ข ํฉ ์ ๋ฌผ์ธํธ!
์ ์ฉํ ์ปค์คํ ํ ์ ๋ชจ์๋์ ์ฝ๋ ์ ์ ์ฅ์ ๐
์ปค์คํ
(์ฌ์ฉ์ ์ ์)ํ
์ค๋ ๊ธฐ๋ณธ์ ์ผ๋ก ์ ๊ณต๋๋ Hooks API๋ฅผ ์ฌ์ฉํ์ฌ ์๋ก์ด ํจ์๋ฅผ ์ฌ์ ์ํ ํ
์ค๋ฅผ ๋งํ๋ค. ์ปค์คํ
ํ
์ค์ ๋ค์ด๋ฐ์ ํญ์ use
๋ก ์์ํด์ผํ๋ค. ์ฌ๊ธฐ์๋ ๋ช ๊ฐ์ง ์ปค์คํ
ํ
์ค๋ฅผ ๋ง๋ค์ด ๋ณผ ๊ฒ์ด๋ค.
-
์ฌ๋ฌ ๊ฐ์ ์ปดํผ๋ํธ์์ ์ํ ๊ด๋ จ ๋ก์ง์ด ์ค๋ณต๋ ๋, ์ปค์คํ ํ ์ ๋ง๋ค์ด์ ์ฌ์ฌ์ฉํ ์ ์๋ค.(reusable)
-
์ฌ๋ฌ ๊ฐ์ ๋ก์ง์ ๋ถ๋ฆฌํ๊ณ ์ถ์ ๋, ์ปค์คํ ํ ์ ๋ง๋ค์ ์๋ค.(encapsulated)
-
์ปค์คํ ํ ์ ๋ง๋ฆ์ผ๋ก์ ํ ์คํธํ๊ธฐ ์ฉ์ดํด์ง๋ค.(testable)
-
์ผ๋ฐ์ ์ผ๋ก ์ปค์คํ ํ ์ ํน์ ๊ฐ์ ๋ฐํํ๋ค. (์ด ๋ถ๋ถ์ ๋ฌด์กฐ๊ฑด์ ์๋๋ฉฐ, ์ปดํผ๋ํธ ํน์ ๋งํฌ์ ๋ ๋ฐํ๊ฐ๋ฅํ๋ค.)
-
Practical React Hooks :
Learn by Building 10 Hooks
with Nomad Coders
๊ฐํธ
-
hooks๋ฅผ ์ด์ฉํ ํ๋ก์ ํธ : nextjs์์ ์ฌ์ฉ
- Lotto Game
- TicTacToe
- TodoApp
- Mine Sweeper
[์ฐธ๊ณ ] https://www.youtube.com/playlist?list=PLcqDmjxt30RtqbStQqk-eYMK8N-1SYIFn
- 2048 : https://play2048.co/ (์ค์ -๋ฆฌ์กํธ-ํ๋ก๊ทธ๋๋ฐ : part1)
-
์๋ก์ด hooks์ ๋ํ ์ดํด https://ko.reactjs.org/docs/hooks-reference.html https://betterprogramming.pub/5-new-hooks-in-react-18-300aa713cefe
-
custom hooks : https://www.freecodecamp.org/news/react-hooks-every-project-should-use/
-
https://github.com/mantinedev/mantine : ์ด ํ๋ก์ ํธ๋ฅผ ๋ถ์ํ๋ฉด์ ์ง์ ๊ตฌํํด๋ณด๊ธฐ!
docs https://ko.reactjs.org/docs/hooks-intro.html
-
intro ๊ฐ์
-
hooks์ ๋ฑ์ฅ > ์ด๋ค ๋ฌธ์ ๋ฅผ ํ๊ธฐ ์ํด ๋ํ๋ ์ํผ๋งจ์ธ์ง
https://blog.logrocket.com/understanding-common-frustrations-react-hooks/
-
hooks mechanism > ์ ์ฐ๋ฆฌ๋ ํ ์ค ๊ท์น์ ์ง์ผ์ผํ๋๊ฐ?
https://www.netlify.com/blog/2019/03/11/deep-dive-how-do-react-hooks-really-work/ https://hridoybanik.medium.com/mechanism-of-react-hooks-e59e8f3c65d https://indepth.dev/posts/1220/under-the-hood-of-react-hooks > + react fiber
hooks์ ์์
- ์ค์ ์ด๋ป๊ฒ ์ฌ์ฉํ๋์ง...
- jqeury ์ปดํผ๋ํธ ์ฌ์ฉ