2021. 4. 29. 10:05ㆍFrontend/React
State is immutable, that's the rule of redux.
Mutaion in state is not recommended.
Instead mutating the state, just return another object. for example using filter method in array state is a. good method to delete some elements in array. Because filter() method just return a new state(array) instead mutate a state.
Redux is just a function.
Dispatching actions, and modifying the data(states) through the actions.
it is good to separate functions as its minimum responsiblity, dispatchors should only perform dispatching actions, and those actions will get an action type and data(payload).
So that the reducers will change the state(data) and we can use those updated data through the 'getState() method'.
In Redux Middleware, Reducer is the only place that states of data modified, so that it is easy to handle the data and states.
If we don't use Redux, all data and states are handled in the component level which will occur big difficulty in controlling data because the states will be separated in all of components.
Actions are object,{}.
Store is the place/function to store the data(state).
결국 상태라는 것이 변화하는 경우는 CRUD 중 CUD 에 해당하고,
상태,state라는 immutable한 객체를 변경하기 위한 이 세 과정(CUD)의 방법은 어느정도 정형화 되어있다.
'Frontend > React' 카테고리의 다른 글
[recoil] Error: Invalid hook call (1) | 2021.06.08 |
---|---|
React - netlify로 배포하기 (feat. github) (1) | 2021.05.26 |
React 리액트 - 중첩 객체의 state 변경 (0) | 2021.02.20 |
setState의 비동기성으로 생기는 문제 (0) | 2021.02.05 |
[React tutorial] 배열 객체 렌더링하기 (입문) (0) | 2020.11.10 |