Redux Action

2021. 7. 31. 16:03React

Action 정의

Reducer 만들기

Reducer를 인자로 단일 Store를 만든다.

 

Redux의 Action 형태

  • {type: 'TEST'} // payload 없음
  • {type: 'TEST', params: 'test1'} //payload 존재
  • function 액션생성자(...args) { return 액션; }
  • createTest('test1'); // {type: 'TEST', params: 'test1'}을 리턴

Redux의 Action이 하는 일

  • action 생성자에서 액션을 만듬
  • action 객체를  redux store에 보냄
  • redux store가 action 객체를 받으면 store의 상태 값이 변경
  • 변경된 상태값을 사용하고 있는 component가 변경

 

1
2
3
4
5
export const ADD_TODO = 'ADD_TODO';
 
export function addTodo(text) {
  return { type: ADD_TODO, text};
}
cs

'React' 카테고리의 다른 글

Redux Store  (0) 2021.07.31
React Reducer  (0) 2021.07.31
React Reconciliation  (0) 2021.07.30
react-router-dom Redirect  (0) 2021.07.27
react-router-dom에서 페이지 이동시 Link component 사용  (0) 2021.07.27