본문 바로가기
error | tip/error

Uncaught Invariant Violation: defaultState for reducer handling [object Object] should be defined

by meno1011 2022. 9. 26.
728x90

Uncaught Invariant Violation: defaultState for reducer handling [object Object] should be defined

에러!!

redux-actions로 리듀서를 작성하는 도중 발생 reducer를 여러개 사용할 경우 handleAction → handleActions 변경하여 사용해야한다.

// 수정 전
import { handleAction } from "redux-actions"
const reducer = handleAction({
	[INITIALIZE]: (state)=>initialState,
},initailState)

// 수정 후
import { handleActions } from "redux-actions"
const reducer = handleActions({
	[INITIALIZE]: (state)=>initialState,
},initailState)

위 코드처럼 변경해주면 해결됩니당~