- Published on
Redux μμνκΈ° π₯
- Authors
- Name
- Haneul
Redux 리λμ€
: 리μ‘νΈλ₯Ό μν μ€ν μ΄νΈ 맀λμ§λ¨ΌνΈ ν΄ (볡μ‘ν μ±μμ ν¨μ¨μ , λ¨μν μ±μμ νμμμ)
Why do we need it? μ νμνκ°?
- Components have local state, but apps have global state.
- Sometimes state need to be shared.
- We need to save the shared state somewhere.
- Redux == state container
Redux is a gloabl state container
- Ther Redux Store is like a box
- We go and grab what we need for the container
- For example, from
<Navigation/>
we only grab the username
Stuff to remember
- The whole state of your app is stored in an object(store)
- state κ° λ³΅μ‘νκ³ μ»€μ§ μ μμ΄μ 리λμ€λ ν΄λΉ μ€λΈμ νΈλ₯Ό μμ νλ κ²μ λ§€μ° μ격ν¨
- If you wanna change the data inside of this object you need to 'dispatch' (sned) an action
- μ€λΈμ νΈμ λ°μ΄ν°λ₯Ό μμ νλ λ°©λ²μ μ‘μ μ reducer λ‘ λ³΄λ΄λ©΄ κ°λ₯ν¨
- You will send this actions to a reducer and this reducer will change the object for you.
- reducer λ μ¬μ©μλ₯Ό λμ ν΄ μ€λΈμ νΈλ₯Ό λ³κ²½ν¨