redux tutorial

2021. 4. 29. 10:05React

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)의 방법은 어느정도 정형화 되어있다.