-
Notifications
You must be signed in to change notification settings - Fork 0
Create Week9 Mission1,2,3, #113
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
hyesngy
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
μ λ§ κ³ μ λ§μΌμ ¨μ΅λλ€! ππ»ππ»ππ»
μ΄λ² μ£Ό μν¬λΆμ ν΅ν΄ Redux Toolkitκ³Ό Zustand λ κ°μ§ μνκ΄λ¦¬ λΌμ΄λΈλ¬λ¦¬λ₯Ό λͺ¨λ λ€λ€λ³΄μμ΅λλ€. μμΌλ‘ νλ‘μ νΈ λ³΅μ‘λλ κ·λͺ¨μ λ°λΌ μ μ ν μνκ΄λ¦¬ λꡬλ₯Ό μ νν μ μλ μλͺ©μ κ°μΆκ² λμ
¨μΌλ©΄ μ’κ² μ΅λλ€! ππ»ππ»ππ»
| import { configureStore } from "@reduxjs/toolkit"; | ||
| import cartReducer from "../slices/cartSlice"; | ||
| import modalReducer from "../slices/modalSlice"; | ||
|
|
||
| function createStore() { | ||
| const store = configureStore({ | ||
| reducer: { | ||
| cart: cartReducer, | ||
| modal: modalReducer, | ||
| }, | ||
| }); | ||
| return store; | ||
| } | ||
|
|
||
| const store = createStore(); | ||
| export default store; | ||
|
|
||
| export type RootState = ReturnType<typeof store.getState>; | ||
| export type AppDispatch = typeof store.dispatch; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
νμ¬ μ₯λ°κ΅¬λ λ°μ΄ν°κ° μλ‘κ³ μΉ¨ μ μ΄κΈ°νλκ³ μλλ°, Redux Toolkitμ redux-persistλ Zustandμ persist λ―Έλ€μ¨μ΄λ₯Ό μ μ©νμ¬, μλ‘κ³ μΉ¨ νμλ μ₯λ°κ΅¬λ μνκ° μ μ§λλλ‘ πChallenge λ―Έμ
μ λμ ν΄ λ³΄μλ©΄ μ’κ² μ΅λλ€!
| const Modal = () => { | ||
| const dispatch = useDispatch(); | ||
| const isOpen = useSelector((state) => state.modal.isOpen); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
νμ¬ λ―Έμ 3μμ μ₯λ°κ΅¬λλ Zustandλ‘ μ κ΄λ¦¬νκ³ μμ§λ§, λͺ¨λ¬μ μμ§ Reduxλ‘ κ΄λ¦¬νκ³ μμ΄ νΌμ¬λ μνμ λλ€.
Modal.tsxμμ useDispatchμ useSelectorλ₯Ό μ¬μ©νμ¬ Reduxμ modalSliceλ₯Ό μ°Έμ‘°νκ³ μκ³ , PriceBox.tsxμμλ openModal μ‘μ
μ Reduxλ‘ λμ€ν¨μΉνκ³ μμ΅λλ€. λͺ¨λ¬ μν κ΄λ¦¬λ Zustandλ‘ μμ ν λ§μ΄κ·Έλ μ΄μ
ν΄μΌ ν©λλ€.
| function App() { | ||
| return ( | ||
| <Provider store={store}> | ||
| <Navbar /> | ||
| <CartList /> | ||
| <Modal /> | ||
| <PriceBox /> | ||
| </Provider> | ||
| ); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
νμ¬ λ―Έμ
3μ App.tsx μμ Reduxμ Providerλ‘ κ°μΈκ³ μλλ°, λ―Έμ
3μμλ Zustandλ‘ μν κ΄λ¦¬λ₯Ό μ ννκΈ° λλ¬Έμ μ΄ λΆλΆμ μ κ±°ν΄μΌ ν©λλ€. λν, store.ts, cartSlice.ts λ± Redux κ΄λ ¨ νμΌλ€μ΄ μ¬μ ν λ¨μμλλ°, νλ‘μ νΈ κ΅¬μ‘°λ₯Ό λͺ
ννκ² νκΈ° μν΄ ν΄λΉ νμΌλ€λ μ κ±°νλ κ²μ κΆμ₯ν©λλ€!
hyesngy
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
10μ£Όμ°¨ μν¬λΆκΉμ§ μ λ§ κΈ΄ μ¬μ μ΄μμ΅λλ€.
κ·Έλμ λͺ¨λ κ³ μ λ§μΌμ ¨μ΅λλ€! ππ»ππ»ππ» μ§§μ§ μμ κΈ°κ°λμ μλ―Έ μλ μκ°μ΄ λμκΈ°λ₯Ό λ°λλλ€.
μ΄μ κΈ°λ³Έ μν¬λΆμ λͺ¨λ μμ£Όνμ ¨μ§λ§, 11-12μ£Όμ°¨ μν¬λΆλ λμ ν΄λ³΄μκΈΈ μΆμ²λ립λλ€! 11μ£Όμ°¨μμλ Vercelμ νμ©ν λ°°ν¬μ CI/CD ꡬμ±μ λ€λ£¨κ³ , 12μ£Όμ°¨μμλ WebSocketμ μ΄μ©ν μ€μκ° ν΅μ κ³Ό Cypressλ₯Ό νμ©ν E2E ν μ€νΈλ₯Ό λ€λ£Ήλλ€.
μμΌλ‘λ κΎΈμ€ν νμ΅νκ³ μ±μ₯νμκΈΈ μμνλ©°, λ°λͺ¨λ°μ΄κΉμ§ νμ΄ν μ λλ€! ππ»ππ»ππ»
| const useFetch = <T>(url: string, options?: AxiosRequestConfig) => { | ||
| const [data, setData] = useState<string | null>(null); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
νμ¬ useFetchμμ μ λ€λ¦ <T>λ₯Ό μ μΈν΄λ¨μ§λ§ μ€μ λ‘λ νμ©νμ§ λͺ»νκ³ μλ μν©μ
λλ€.
useState<string | null>(null)λ‘ νλμ½λ©λμ΄ μμ΄μ Homepage.tsxμμ useFetch<MovieResponse>λ‘ νΈμΆν΄λ dataμ νμ
μ΄ stringμΌλ‘ κ³ μ λμ΄ λ²λ¦½λλ€.
μ΄λ‘ μΈν΄ data?.resultsμ μ κ·Όν λ TypeScriptκ° μ¬λ°λ₯Έ νμ
μΆλ‘ μ νμ§ λͺ»νκ³ , λ°νμμμ μμμΉ λͺ»ν μλ¬κ° λ°μν μνμ΄ μμ΅λλ€. μ λ€λ¦ νμ
Tλ₯Ό νμ©νμ¬ useState<T | null>(null)λ‘ μμ νλ©΄ νΈμΆνλ κ³³μμ μ§μ ν νμ
(MovieResponse)μ΄ μ λλ‘ λ°μλμ΄ νμ
μμ μ±μ΄ ν¬κ² ν₯μλ κ²μ
λλ€!
| const useFetch = <T>(url: string, options?: AxiosRequestConfig) => { | |
| const [data, setData] = useState<string | null>(null); | |
| const useFetch = <T>(url: string, options?: AxiosRequestConfig) => { | |
| const [data, setData] = useState<T | null>(null); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
νμ¬ μ½λλ₯Ό 보면 10μ£Όμ°¨ μν¬λΆ λ―Έμ μΈ κ²μ κΈ°λ₯μ μ§μ€ν κ΅¬μ‘°λ‘ λμ΄ μλλ°, μ§λ λ―Έμ μ΄μλ μν νμ΄μ§μ ν΅ν©νλ©΄ λ μμ±λ λμ μν μ¬μ΄νΈκ° λ κ² κ°μ΅λλ€!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
πChallenge λ―Έμ μ λ°λΌ νλ‘μ νΈ μ 체μ μ±λ₯ μ΅μ νλ UX κ°μ μλ λμ ν΄λ³΄μΈμ! μ½λ νμ§ μΈ‘λ©΄μμλ μ€λ³΅ μ κ±°, μ± μ λΆλ¦¬, μμΈ μ²λ¦¬ κ°μ λ±μ ν΅ν΄ κ°λ μ±κ³Ό μ μ§λ³΄μμ±μ΄ μ’μ μ½λλ‘ λ¦¬ν©ν λ§ ν΄λ³΄λ©΄ μ΄λ¨κΉμ π
π λ―Έμ λ²νΈ
9μ£Όμ°¨ Mission1,2,3,
π ꡬν μ¬ν
-modalμ ν΅ν΄ μ§μ§ μμ ν κ±΄μ§ λνλ
π μ€ν¬λ¦°μ·
β 체ν¬λ¦¬μ€νΈ
π€ μ§λ¬Έ μ¬ν