Redux
State Manager
- Without
each component has its own storage => spaghetti code - With
has one store without having each storage
- predictable state container for JavaScript applications
- unpredictable; random bugs, hard to fix
- application-wide state
- reduce function
react component = view
Reducer
- can have multiple reducers
- receives a state and do an action
- reduce function
- specify how the applicationโs state changes in response
- pure function
- never do something like : mutate arguments, callign an API, call non-pure function
identity reducer
- getState()
- dispatch(action)
- subscribe(listener)
๐but normally uses hooks๐
Hooks
โป for React
react-query.tanstack.com/reference/useQuery
useQuery
Subscribe to our newsletter The latest TanStack news, articles, and resources, sent to your inbox.
react-query.tanstack.com
useReducer
ko.reactjs.org/docs/hooks-reference.html
Hooks API Reference โ React
A JavaScript library for building user interfaces
ko.reactjs.org
Making To-Do List
๐ redux devTools
Do one thing -> make sure it is working -> move on to next one๏ปฟ
overview Tree
big loop
- dispatch: sends the action to the reducer => actions in loop
index.js
๐simplified
- < TodoItem todo = {todo} onChange={onChangeTodo} >
โป Single component as a single responsibility
- Presentational Component
blog.naver.com/backsajang420/221368885149
[React] Presentational and Container Components
[React] ํ๋ ์ ํ ์ด์ ์ปดํฌ๋ํธ์ ์ปจํ ์ด๋ ์ปดํฌ๋ํธ (Presentational and Container Components)# ์โฆ
blog.naver.com
ํ๋ ์ ํ ์ด์ ์ปดํฌ๋ํธ (Presentational Component)
ํ๋ ์ ํ ์ด์ ์ปดํฌ๋ํธ(Presentational Component) ๋ ์๋์ ๊ฐ์ ์ฑ์ง์ ๊ฐ๋๋ค.
โ ์ด๋ป๊ฒ ๋ณด์ฌ์ง๋ ์ง๋ฅผ ์ฑ ์์ง๋ค.
์ปจํ ์ด๋ ์ปดํฌ๋ํธ (Container Component)
์ปจํ ์ด๋ ์ปดํฌ๋ํธ(Container Component) ๋ ์๋์ ๊ฐ์ ์ฑ์ง์ ๊ฐ๋๋ค.
โ ์ด๋ป๊ฒ ๋์ํด์ผ ํ ์ง๋ฅผ ์ฑ ์์ง๋ค.