diff --git a/.coderabbit.yaml b/.coderabbit.yaml
new file mode 100644
index 0000000..ecb145c
--- /dev/null
+++ b/.coderabbit.yaml
@@ -0,0 +1,14 @@
+language: ko-KR
+early_access: false
+reviews:
+ profile: "chill"
+ request_changes_workflow: false
+ high_level_summary: true
+ poem: false
+ review_status: true
+ collapse_walkthrough: false
+ auto_review:
+ enabled: true
+ drafts: false
+chat:
+ auto_reply: true
diff --git a/05-effects/README.md b/05-effects/README.md
new file mode 100644
index 0000000..3c445ae
--- /dev/null
+++ b/05-effects/README.md
@@ -0,0 +1,49 @@
+# 05. API ์ฐ๋ํ๊ธฐ: side-effect(feat. effects)
+
+## ๐ฏ ์๊ตฌ ์ฌํญ
+- API๋ก ๋ ์คํ ๋ ๋ชฉ๋ก์ ๋ถ๋ฌ์ ``์ ๋ด๋ ค์ค๋๋ค.
+ - ๋ก๋ฉ ์ํ, ์๋ฌ ์ํ ๋ฑ์ ๊ณ ๋ คํ์ง ์์ต๋๋ค.
+- ๋ ์คํ ๋ ์ถ๊ฐ ๋ชจ๋ฌ์์ ์ถ๊ฐํ๊ธฐ ๋ฒํผ์ ํด๋ฆญํ๋ฉด POST ์์ฒญ์ ๋ณด๋
๋๋ค. ๋ชจ๋ฌ์ด ๋ซํ๊ณ , ๋ ์คํ ๋ ๋ชฉ๋ก์ ๋ค์ ๋ถ๋ฌ์ต๋๋ค.
+
+## โ
ํค์๋
+- effect (feat. side effect)
+ - useEffect
+
+## ๐งโโ๏ธ ์งํ ๊ฐ์ด๋
+
+- ์งํ ์๊ฐ: 2์๊ฐ ๋ด์ ์๋ฃํ๋ ๊ฒ์ ๋ชฉํ๋ก ํฉ๋๋ค.
+
+### `json-server`๋ก ๊ฐ์ง ์๋ฒ ๋์ ํ์ฉํ๊ธฐ
+์ฐ์ต์ฉ ์ฑ์ด๊ธฐ ๋๋ฌธ์ [`json-server`](https://github.com/typicode/json-server)๋ฅผ ํ์ฉํด ๊ฐ๋จํ ๊ฐ์ง REST API๋ฅผ ๊ตฌ์ถํด ์ฌ์ฉํฉ๋๋ค.
+- `npm run server`๋ฅผ ์คํํฉ๋๋ค. (ํน์ `npx json-server db.json` ๋ฅผ ์ง์ ์คํํด๋ ์๊ด์์ต๋๋ค)
+- `GET http://localhost:3000/restaurants`์ผ๋ก `db.json`์ ์๋ ๋ ์คํ ๋ ๋ชฉ๋ก์ ๋ถ๋ฌ์ฌ ์ ์์ต๋๋ค.
+```javascript
+// GET ์์
+const response = await fetch("http://localhost:3000/restaurants");
+
+// POST ์์
+const response = await fetch("http://localhost:3000/restaurants", {
+ method: "POST",
+ headers: {
+ "Content-Type": "application/json",
+ },
+ body: JSON.stringify(restaurant),
+});
+```
+
+## ๐ ์ฐธ๊ณ ๋ฌธ์
+- [Synchronizing with Effects](https://react.dev/learn/synchronizing-with-effects)
+> Effects let you specify side effects that are caused by rendering itself, rather than by a particular event.
+ - [API Reference: useEffect](https://react.dev/reference/react/useEffect)
+ > useEffect is a React Hook that lets you synchronize a component with an external system.
+- [API Reference: useSate > updater function](https://react.dev/reference/react/useState#updating-state-based-on-the-previous-state)
+ > `set` function์ ํจ์๋ฅผ ๋๊ฒจ์ฃผ๋ฉด `updater function`์ผ๋ก ๋์ํฉ๋๋ค. ํจ์๊ฐ ์๋ ๊ฐ์ ๋๊ฒจ์ค ๋์ ์ด๋ป๊ฒ ๋ค๋ฅธ์ง ์์๋ณด์ธ์.
+
+๊ตฌํ์ ๋ค ํด๋ณธ ๋ค์ Introduction์์ ์ดํด๋ณด์๋ ์ค๊ณ ์์น๊ณผ ๊ด๋ จํด ์กฐ๊ธ ๋ ํ์ตํด๋ณด๊ณ ์ถ๋ค๋ฉด ์๋ ๋ฌธ์๋ค๋ ์ถ๊ฐ๋ก ํ์ธํด ๋ณด์ธ์.
+- [You Might Not Need an Effect](https://react.dev/learn/you-might-not-need-an-effect)
+> You do need Effects to synchronize with external systems.
+> In React, data flows from the parent components to their children.
+- [Components and Hooks must be pure](https://react.dev/reference/rules/components-and-hooks-must-be-pure)
+> Purity in Components and Hooks is a key rule of React that makes your app predictable, easy to debug, and allows React to automatically optimize your code.
+> Side effects should not run in render, as React can render components multiple times to create the best possible user experience.
+> One important principle in React is local reasoning: the ability to understand what a component or hook does by looking at its code in isolation. Hooks should be treated like โblack boxesโ when they are called.
\ No newline at end of file
diff --git a/README.md b/README.md
index e206bd7..e9671f0 100644
--- a/README.md
+++ b/README.md
@@ -1,181 +1,387 @@
-# ์ฌ์ฌ์ฉ ๊ฐ๋ฅํ ์ปดํฌ๋ํธ ์ค๊ณ
+# API ์์ฒญ๊ณผ ๋น๋๊ธฐ ์ฒ๋ฆฌ
## ๐ฏ ๊ฐ์ธ ๋ชฉํ ๋ฐ ๋ชฉํ ๋ฌ์ฑ์ ์ํ ํ๋ ๊ฐ์ด๋
์ด๋ฒ ๋ฏธ์
์ ํตํด ๋ค์๊ณผ ๊ฐ์ ํ์ต ๊ฒฝํ๋ค์ ์๋ ๊ฒ์ ๋ชฉํ๋ก ํ๋ค.
-1. controlled ์ปดํฌ๋ํธ์ uncontrolled ์ปดํฌ๋ํธ์ ์ฐจ์ด๋ฅผ ์ดํดํ๊ณ , ๊ฐ๊ฐ ์ด๋ค ์ํฉ์์ ์ ํํ๋์ง ๊ธฐ์ค์ ์ธ์ด๋ค.
-2. ์ด๋ค state๋ฅผ ์ด๋ ์ปดํฌ๋ํธ๊ฐ ์์ ํด์ผ ํ๋์ง ํ๋จํ๊ณ , ํ์ํ ๊ฒฝ์ฐ ๊ณตํต ๋ถ๋ชจ๋ก ๋์ด์ฌ๋ฆฌ๋ ํจํด(Lifting State Up)์ ๊ฒฝํํ๋ค.
-3. `children` props๋ฅผ ํ์ฉํด ์ฌ์ฌ์ฉ ๊ฐ๋ฅํ Modal ์ปดํฌ๋ํธ๋ฅผ ์ค๊ณํ๋ ๋ฐฉ๋ฒ์ ์ตํ๋ค.
+1. side effect๊ฐ ๋ฌด์์ธ์ง ์ดํดํ๊ณ , `useEffect`๊ฐ ์ ํ์ํ์ง ์ค๋ช
ํ ์ ์๋ค.
+2. Promise๊ฐ ๋ฌด์์ธ์ง ์ดํดํ๊ณ , async/await๊ฐ Promise๋ฅผ ์ด๋ป๊ฒ ๋ค๋ฃจ๋์ง ์ค๋ช
ํ ์ ์๋ค.
+3. `fetch`๋ก GET/POST ์์ฒญ์ ๋ณด๋ด๊ณ ์๋ต์ ์ฒ๋ฆฌํ๋ ๋ฐฉ๋ฒ์ ์ตํ๊ณ , `await`๋ฅผ ์ด๋์ ๋ถ์ฌ์ผ ํ๋์ง ์ค์ค๋ก ํ๋จํ ์ ์๋ค.
---
## ๐ ๊ธฐ๋ฅ ๊ตฌํ ๋ชฉ๋ก
-- [x] Header์ ์์์ ์ถ๊ฐ ๋ฒํผ ํด๋ฆญ ์ AddRestaurantModal ์ด๊ธฐ
-- [x] ์ถ๊ฐํ๊ธฐ ๋ฒํผ ํด๋ฆญ ์ ์์์ ๋ชฉ๋ก์ ํญ๋ชฉ ์ถ๊ฐ
-- [x] ์ฌ์ฌ์ฉ ๊ฐ๋ฅํ Modal ์ปดํฌ๋ํธ๋ก AddRestaurantModal, RestaurantDetailModal ๊ฐ์
+- [x] API๋ก ์์์ ๋ชฉ๋ก์ ๋ถ๋ฌ์ RestaurantList์ ๋ ๋๋ง
+- [x] ์์์ ์ถ๊ฐ ์ POST ์์ฒญ ํ ๋ชฉ๋ก ์ฌ์กฐํ
---
## ๐ ํ์ต ๋ด์ฉ
-### Controlled vs Uncontrolled Component
+### useEffect์ side effect
-์ปดํฌ๋ํธ์ ์ค์ํ ์ ๋ณด๊ฐ **props**์ ์ํด ๊ฒฐ์ ๋๋ฉด controlled, **์ง์ญ state**๋ก ์์ฒด ๊ด๋ฆฌ๋๋ฉด uncontrolled์ด๋ค.
+React ์ปดํฌ๋ํธ๋ ๋ ๋๋ง ์ค์ ์ธ๋ถ ์์คํ
(์๋ฒ, ํ์ด๋จธ, DOM ์ง์ ์กฐ์ ๋ฑ)์ ์ํฅ์ ์ฃผ๋ฉด ์ ๋๋ค. ์ด๋ฐ ์์
์ side effect๋ผ๊ณ ํ๊ณ , `useEffect`๋ ๋ ๋๋ง์ด ๋๋ ๋ค ์ด๋ฅผ ์์ ํ๊ฒ ์คํํ๋ ๊ณต๊ฐ์ด๋ค.
-| | Controlled | Uncontrolled |
-|---|---|---|
-| ์ ๋ณด ์ถ์ฒ | props (๋ถ๋ชจ๊ฐ ์ ๊ณต) | ์ง์ญ state (์์ฒด ๊ด๋ฆฌ) |
-| ๋ถ๋ชจ์ ์ํฅ | ๋์์ ์์ ํ ์ง์ ๊ฐ๋ฅ | ์ํฅ์ ์ค ์ ์์ |
-| ์ ์ฐ์ฑ | ์ฌ๋ฌ ์ปดํฌ๋ํธ์ ์กฐ์ ์ฉ์ด | ๋
๋ฆฝ์ ์ด์ง๋ง ํ๋ ฅ ์ด๋ ค์ |
-| ์ฌ์ฉ ๋์ด๋ | ๋ถ๋ชจ์์ props ์ค์ ํ์ | ์ค์ ์ด ์ ์ด ์ฌ์ฉํ๊ธฐ ์ฌ์ |
-
-**์ธ์ ์ ํํ๋?**
-- **Controlled** โ ๋ถ๋ชจ ์ปดํฌ๋ํธ์ state๋ฅผ ๊ณต์ ํ๊ฑฐ๋, ์ฌ๋ฌ ์ปดํฌ๋ํธ์ ๋์์ ํจ๊ป ์กฐ์ ํด์ผ ํ ๋
-- **Uncontrolled** โ ๋ถ๋ชจ์ ์ํ๋ฅผ ๊ณต์ ํ ํ์ ์์ด ๋
๋ฆฝ์ ์ผ๋ก ๋์ํด๋ ๋ ๋
+```jsx
+useEffect(() => {
+ // ๋ ๋๋ง ์ดํ ์คํ โ ์๋ฒ ์์ฒญ, ๊ตฌ๋
, DOM ์กฐ์ ๋ฑ
+}, []);
+```
-**์ด ๋ฏธ์
์์์ ์ ํ:**
+์์กด์ฑ ๋ฐฐ์ด `[]`๋ฅผ ๋๊ธฐ๋ฉด ์ปดํฌ๋ํธ๊ฐ ์ฒ์ ๋ง์ดํธ๋ ๋ ํ ๋ฒ๋ง ์คํ๋๋ค. ๋ฐฐ์ด์ ์์ ์๋ตํ๋ฉด ๋งค ๋ ๋๋ง๋ง๋ค ์คํ๋์ด ๋ฌดํ ๋ฃจํ๊ฐ ์๊ธธ ์ ์๋ค.
-controlled/uncontrolled๋ ์ปดํฌ๋ํธ ์ ์ฒด์ ๋ถ์ด๋ ๋ ์ด๋ธ์ด ์๋๋ผ, ์ด๋ค ์ ๋ณด๊ฐ ์ด๋์ ๊ด๋ฆฌ๋๋์ง๋ฅผ ๊ธฐ์ค์ผ๋ก ํ๋จํ๋ค. AddRestaurantModal์ ๋ ๊ฐ์ง๊ฐ ํผ์ฌํ๋ค.
+### useEffect ์์์ async/await ์ฐ๋ ๋ฒ
-- **ํผ ๋ฐ์ดํฐ** (category, name, description) โ ์ง์ญ state๋ก ์์ฒด ๊ด๋ฆฌ โ **uncontrolled**
-- **๋ชจ๋ฌ ์ด๋ฆผ/๋ซํ** โ App์ด ์์ โ **controlled**
+`useEffect`์ ์ฝ๋ฐฑ์ ์ง์ `async`๋ก ๋ง๋ค ์ ์๋ค. `async` ํจ์๋ ํญ์ Promise๋ฅผ ๋ฐํํ๋๋ฐ, React๋ `useEffect` ์ฝ๋ฐฑ์ ๋ฐํ๊ฐ์ cleanup ํจ์๋ก ๊ธฐ๋ํ๊ธฐ ๋๋ฌธ์ด๋ค.
-๋ชจ๋ฌ ์ด๋ฆผ ์ํ๋ฅผ App์ด ์์ ํ๋ ์ด์ ๋ ํธ๋ฆฌ๊ฑฐ(Header์ ์ถ๊ฐ ๋ฒํผ)์ ๋ชจ๋ฌ์ด ํ์ ๊ด๊ณ์ด๊ธฐ ๋๋ฌธ์ด๋ค. ํ์ ๋ผ๋ฆฌ๋ ์๋ก์ state์ ์ ๊ทผํ ์ ์์ผ๋ฏ๋ก ๊ณตํต ๋ถ๋ชจ์ธ App์ผ๋ก state๋ฅผ ๋์ด์ฌ๋ ธ๋ค(Lifting State Up).
+```jsx
+// โ ์ด๋ ๊ฒ ํ๋ฉด ์ ๋จ โ async ์ฝ๋ฐฑ์ด Promise๋ฅผ ๋ฐํํด์ React๊ฐ ๊ฒฝ๊ณ
+useEffect(async () => {
+ const data = await getRestaurants();
+ setRestaurants(data);
+}, []);
+
+// โ
๋ด๋ถ์์ async ํจ์๋ฅผ ์ ์ํ๊ณ ํธ์ถ
+useEffect(() => {
+ const fetchRestaurants = async () => {
+ const data = await getRestaurants();
+ setRestaurants(data);
+ };
+ fetchRestaurants();
+}, []);
+```
-`onSubmit`, `onClose`๋ state๊ฐ ์๋ ์ฝ๋ฐฑ์ด๋ค. "์ด๋ค ๊ฐ์ ๋๊ฐ ์์ ํ๋"์ ๋ฌธ์ ๊ฐ ์๋๋ผ ์ด๋ฒคํธ๋ฅผ ๋ถ๋ชจ๋ก ์ ๋ฌํ๋ ํต๋ก์ด๋ฏ๋ก controlled/uncontrolled ๊ตฌ๋ถ๊ณผ๋ ๋ณ๊ฐ๋ค.
+### async/await๋ฅผ ์ด๋์ ๋ถ์ฌ์ผ ํ๋๊ฐ
-### form submit ๊ธฐ๋ณธ ๋์๊ณผ e.preventDefault()
+`await`๋ Promise๋ฅผ ๋ฐํํ๋ ํจ์ ์์ ๋ถ์ธ๋ค. `await`๋ฅผ ์ฐ๋ ํจ์ ์์ ์ ๋ฐ๋์ `async`์ฌ์ผ ํ๋ค. ์ด ๊ท์น์ด ํธ์ถ ์ฒด์ธ์ ๋ฐ๋ผ ์ ํ๋๋ค.
-`