Note
'Quick Start' ์ฑํฐ๋ ๋ค์๊ณผ ๊ฐ์ ๋ด์ฉ์ ๋ค๋ฃน๋๋ค.
- ์ปดํฌ๋ํธ๋ฅผ ๋ง๋ค๊ณ ์ค์ฒฉํ๋ ๋ฐฉ๋ฒ
- ๋งํฌ์ ๊ณผ ์คํ์ผ์ ์ถ๊ฐํ๋ ๋ฐฉ๋ฒ
- ์๋ฐ์คํฌ๋ฆฝํธ ๋ฐ์ดํฐ๋ฅผ ํ์ํ๋ ๋ฐฉ๋ฒ
- ์กฐ๊ฑด์ ๋ฐ๋ผ ๋๋ ๋ฆฌ์คํธ๋ฅผ ๋ ๋๋งํ๋ ๋ฐฉ๋ฒ
- ์ด๋ฒคํธ์ ์๋ตํ๊ณ ํ๋ฉด์ ์ ๋ฐ์ดํธํ๋ ๋ฐฉ๋ฒ
- ์ปดํฌ๋ํธ ๊ฐ์ ๋ฐ์ดํฐ๋ฅผ ๊ณต์ ํ๋ ๋ฐฉ๋ฒ
-
React components are JavaScript functions that return markup:
- ์ปดํฌ๋ํธ๊ฐ ์๋ฐ์คํฌ๋ฆฝํธ ํจ์๋ผ๋ ์ ์ด ํต์ฌ์ธ ๋ฌธ์ฅ์ผ๋ก, ํจ์๋ผ๋๊ฑธ ์๊ธฐ์ํค๋ ๋ฌธ์ฅ!
-(https://www.youtube.com/watch?v=MSq_DCRxOxw&t=141s) SOLID ๊ด๋ จ์์ ์ปดํฌ๋ํธ ์ ๋ฆฌ์ ์ฐธ๊ณ ํ๊ธฐ ์ข์ ์์์ผ๋ก ๊ณต์ ํด์ฃผ์ฌ๐
- ์ปดํฌ๋ํธ๊ฐ ์๋ฐ์คํฌ๋ฆฝํธ ํจ์๋ผ๋ ์ ์ด ํต์ฌ์ธ ๋ฌธ์ฅ์ผ๋ก, ํจ์๋ผ๋๊ฑธ ์๊ธฐ์ํค๋ ๋ฌธ์ฅ!
-
JSX lets you put markup into JavaScript. Curly braces let you โescape backโ into JavaScript so that you can embed some variable from your code and display it to the user. For example, this will display user.name:
- JSX๋ฅผ ์ฌ์ฉํ๋๊ฑด ๊ฒฐ๊ตญ jsํ์ฅํ์ผ, ๊ฒฐ๊ตญ ๋ฆฌ์กํธ์์ js๋ก ๋ฐ๊ฟ๋์ฃผ๋๊ฒ
- Q: '? {isLoggedIn && }' ์ฒ๋ผ ์กฐ๊ฑด๋ถ ๊ตฌ๋ฌธ์ด ๋ค๋ฅธ ํ๋ ์์ํฌ์์๋ ์ด๋คํ์์ผ๋ก ์ฌ์ฉ ๋๋๊ฐ?
- A: (Vue) ์์๋ v-if, v-else-if ์ด๋ฐ์์ผ๋ก ์ฌ์ฉ
- Q: ํ์ต๋ฐฉ๋ฒ์ ์ด๋ค์์ธ๊ฐ?
- A: ๋๋ถ๋ถ ๋ฐ๋ผ์น๋๊ฒ์ ์ฐ์ ์ผ๋ก ํ๊ณ ๊ทธํ์ ์ด๋ก ์ ํ์ธํ๋ ๋ฐฉ์, ์ด๋ก ๋จผ์ ์ฝ๊ธฐ์ ๋ถ๋ด์ค๋ฌ์ด๋ฉด์ด ์์
-
In React, a component is a piece of reusable code that represents a part of a user interface. Components are used to render, manage, and update the UI elements in your application.
- ์๋ฐ์คํฌ๋ฆฝํธ์์ UI์ฒ๋ผ ์ฌ์ฌ์ฉํ๊ฒ์ด ํ์ ์
- ์ปดํฌ๋ํธ๋ ๋ฌด์์ธ๊ฐ์ ๋ํด ์๊ฐํด ๋ณธ ์ ์ด ์๋๋ฐ, ๊ฐ๋จ๋ช ๋ฃํ ์ ๋ฆฌ๋ผ์ ์ธ์ ๊น์
-
In React, itโs conventional to use onSomething names for props which represent events and handleSomething for the function definitions which handle those events.
- ์คํฐ๋ 1์ฃผ์ฐจ์ ๊ฐ๊ธฐ ๋ฌ๋ผ ์ปจ๋ฒค์ ์ ๋ง์ถ๊ธฐ ์ด๋ ต๋ค๊ณ ์ธ๊ธํ๋๋ฐ, ๊ณต์๋ฌธ์์ ์ด๋ฐ ๋ถ๋ถ(on, handle)์ ์ ํด์ค์ ์ด ๊ธฐ์ค์ ๋ฐ๋ฅด๋ฉด ์ข๊ฒ ๋ค๊ณ ์๊ฐ
- ๋ค๋ฅธ ์ฌ๋๊ณผ ํ์ ํ์ฌ ํจ์๋ช ์งค ๋ ๋งค๋ฒ on๊ณผ handle์ด ์์ด๊ฒ ๋์ด์ ๋ ์ค ํ๋๋ก ํต์ผํด์ผ ํ๋ ๊ณ ๋ฏผํ์๋๋ฐ, ์์ผ๋ก๋ ์ด๊ฑธ ๊ธฐ์ค์ผ๋ก ๋๊ณ ์์ ํด์ผ๊ฒ ๋ค ์๊ฐ
-
Immutability makes it very cheap for components to compare whether their data has changed or not avoid redundant state. Simplifying what you store in state reduces bugs and makes your code easier to understand.
- ๋ถ๋ณ์ฑ์ ์ฅ์ 2๊ฐ์ง๋ก ์ต์ ํ ์ ๋ ์ฌ์ด ์ฝ๋์ ์ดํด๊ฐ ์์
- ๋ถ๋ณ์ฑ์ ์งํค๋ฉด์ ์์ ํด์ผ ํ๋ค๊ณ ์ธ์์ ํ๊ณ ์์๋๋ฐ, ๊ทธ ์ด์ ์ค ํ๋๊ฐ ์ต์ ํ์๋จ ๊ฑธ ์๊ฒ๋จ
-
JavaScript supports closures which means an inner function (e.g. handleClick) has access to variables and functions defined in a outer function (e.g. Board). The handleClick function can read the squares state and call the setSquares method because they are both defined inside of the Board function.
- ํด๋ก์ ๋ฅผ ์ง์ํ๋ฏ๋ก ๋ด๋ถํจ์๊ฐ ์ธ๋ถ ํจ์์ ์ ์๋ ๋ณ์ ๋ฐ ํจ์์ ์์ธ์คํ ์ ์์
- ํด๋ก์ ๋ฅผ ๋ช ํํ ์ค๋ช ํด์ค์ ์ข์
-
You donโt need useState for thisโyou already have enough information to calculate it during rendering:
- ๊ฐ๋ฐ์ ์งํํ๋ค ๋ณด๋ฉด useState๋ฅผ ๋จ๋ฐํ๋ ๊ฒฝ์ฐ ๊ฐ ๋ฐ์ํ๋๋ฐ, ๋จ๋ฐ์์ด ํ๋๋ฐฉ๋ฒ์ ๊ณ ๋ คํ๋๊ฒ์ด ์ต์ ํ์ ์ข๋ค๊ณ ์๊ฐ
-
Thereโs no reason for you to store both of these in state. In fact, always try to avoid redundant state. - ์ํ์ ์ค๋ณต์ ํผํ๋๊ฒ ๊ฐ๋จํ ์ต์ ํ ๋ฐฉ๋ฒ์ด๋ผ๊ณ ์๊ฐ
-
One such technique is theย single responsibility principle, that is, a component should ideally only do one thing.
- ๊ธํ๊ฒ ์์ ์ ํ ์ปดํฌ๋ํธ์ ์ฌ๋ฌ๊ฐ์ง๋ฅผ ๋ชฐ์ ๋ฃ๋๋ผ ์ด๋ฐ ์์น์ ๊นจ๋ ๊ฒฝ์ฐ๊ฐ ๋ง๋ค๊ณ ๋๋, ๋ฆฌํฉํ ๋ง ๋จ๊ณ์์ ์ด๋ฅผ ๊ฐ์ ํจ
-
Itโs often easier to build the static version first and add interactivity later. Building a static version requires a lot of typing and no thinking, but adding interactivity requires a lot of thinking and not a lot of typing.
- UI๋ฅผ ๋ง๋ค๊ณ ํ๋๊ฒ ํต์์ ์ธ ์์๊ตฌ๋..
-
If your JSON is well-structured, youโll often find that it naturally maps to the component structure of your UI. Thatโs because UI and data models often have the same information architectureโthat is, the same shape. Separate your UI into components, where each component matches one piece of your data model.
- api๊ฐ ํ๋ฉด์ ์ต์ ํ ๋์ ์ ๋ฌ ๋ฐ์ง ์์์ ์ปดํฌ๋ํธ ๊ตฌ์กฐ์ ์์ฐ์ค๋ฝ๊ฒ ๋งคํ์ด ๋๋? ๋ผ๋ ์๊ฐ์ด ๋ฌ
-
- Does it remain unchanged over time? If so, it isnโt state.
- Is it passed in from a parent via props? If so, it isnโt state.
- Can you compute it based on existing state or props in your component? If so, it definitely isnโt state!
- ๋ฆฌ์กํธ์์ ์ํ๋ผ๋๊ฑด ์ค์ํ ๊ฐ๋ ์ด๊ฑธ ์ ๊ตฌ๋ถํ๋ค๋ฉด ์ต์ํ์ ์ต์ ํ๋ ์ฝ๋๋ฅผ ๋ง์ถ ์ ์๋ค๊ณ ์๊ฐ
- Q: (1๋ฒ ๊ด๋ จ) ์ด๋ค์์ผ๋ก ์ฝ๋๋ฅผ ์์ฑ ํ๋๊ฐ?
- A: ๋๋ถ๋ถ ์ฝ๋ ์์ฑ ํ์ ์ชผ๊ฐ๋ํธ, ์๊ฒ ๋ง๋ ํ ์กฐ๋ฆฝํ๋ ๋ฐฉ์์ด ์คํ๋ ค ์ด๋ ต๊ฒ ๋๊ปด์ง๋๊ฐ ์์
- A:
You can either build โtop downโ by starting with building the components higher up in the hierarchy (like FilterableProductTable) or โbottom upโ by working from components lower down (like ProductRow). In simpler examples, itโs usually easier to go top-down, and on larger projects, itโs easier to go bottom-up. ์ด๋ฐ ๋ฐฉ๋ฒ๋ ์กด์ฌํ๊ณ , ์ฝ๋ ์์ฑ์ ํด๋ณด๋ ํํฅ์์ด ๋์ฝ๋ค๊ณ ๋๊ปด์ง
- Q: (2๋ฒ ๊ด๋ จ) ๋ค๋ฅธ๋ถ๋ค์ ์ด๋ค ์์๋ก ์งํ ๋๋๊ฐ?
- A: Api๊ฐ ์๋์ํ์์ ๋์์ธํ๊ณ ๋ฒก์๋ ๊ฐ๋ฐ ์๋ฃ ํ ๊ธฐ๋ฅ ์ด์ด ๋ถ์
- Q: (3๋ฒ ๊ด๋ จ) ๋ฐฑ์๋์ ํ์ ํ์ฌ api์ ํ๋ฉด์ ๋ง์ถ๋ ํธ์ธ๊ฐ? ์๋๋ฉด ๊ทธ๋ฅ ์ฃผ๋๋๋ก ํ๋ ํธ์ธ๊ฐ?
- A: ํ์ํ๊ฐ๋ง ์ฃผ๋ฉด ๊ทธ๊ฑฐ์ ๋ง์ถฐ์ ๊ฐ๊ณตํ๋ํธ์ด๋ค.
- A: ๋ฐฑ์๋ ๊ฐ๋ฐ์๊ฐ ํ๋ฉด์ ์ผ๋๋ง ๊ณ ๋ คํด์ ์ฃผ๋๋์ ๋ฐ๋ผ์ ๋ค๋ฅด๋ค. ํ๋ก์ ํธ ํ๋ฉด์ ๋ฐฑ์๋ ๊ฐ๋ฐ์์ ๋ง์ ํ์
์ด ํ์ํ๋ค.
๐ก ๋ฐํ์๋ Tip.- ๊ณต์๋ฌธ์ ์ค๊ฐ์ค๊ฐ ๋ชจ๋ฅด๋ ๋ด์ฉ์ด ์๋๋ผ๊ณ ๋ค์ชฝ์์ ์ค๋ช ํด์ฃผ๋ ๊ฒฝ์ฐ๊ฐ ๋ง์ผ๋ ๋์ด๊ฐ๋๊ฒ๋ ์ข๋ค!