Land of Joe
[react-redux] Actions must be plain objects. 오류 본문
Actions must be plain objects. Instead, the actual type was: 'function'. You may need to add middleware to your store setup to handle dispatching other values, such as 'redux-thunk' to handle dispatching functions. See https://redux.js.org/tutorials/fundamentals/part-4-store#middleware and https://redux.js.org/tutorials/fundamentals/part-6-async-logic#using-the-redux-thunk-middleware for examples.
dispatch를 통해 (reducer를 호출하고)
action.js에서 가져온 함수 덩어리가 reducer를 거치도록 해야한다.
이때 reducer를 거쳐야하는 것은 plain objects이지, plain objects를 리턴하는 함수가 아니다.
결국, dispatch(action)이 아니라, dispatch(action()) 이러한 형태여야 한다는 소리..!
그 외 공부 기록..
[ reducer.js 기본 구조 ]
[ useDispatch]
- reducer를 호출할 때 import
- 기존에 useState가 처음 선언되던 곳에 사용됨
[ useSelect ]
- 변경된 state를 가져와 사용할 때 import
'🌐 Web > ⚛️ React' 카테고리의 다른 글
Link와 useNavigate의 활용도 차이 (Link태그 내 이벤트 존재 시 이벤트 작동 안 함 문제 해결을 위한 useNavigate 활용) (0) | 2024.04.18 |
---|---|
CRA 생성 안됨 오류 Unknown command: "create-react-app" (0) | 2024.03.01 |
[React] CRA 내 파일 구성에 대한 개인적 고찰 (0) | 2024.01.13 |
[React] 리액트 바보짓은 끝이 없고~~ Module not found: 멈춰! (0) | 2023.07.15 |
[React] modifier 함수, React.useState() (0) | 2023.05.03 |