Reducer "activeBook" returned undefined during initialization
jack1012t opened this issue · comments
I am getting this error despite setting the initial state to null. See below:
reducer_active_book.js:
export default function (state = null, action) {
switch(action.type) {
case 'BOOK_SELECTED':
return action.payload;
}
return state;
}
reducers/index.js
import { combineReducers } from 'redux';
import BooksReducer from './reducer_books';
import ActiveBook from './reducer_active_book'
// this is the mapping of the state
const rootReducer = combineReducers({
books: BooksReducer,
activeBook: ActiveBook
});
export default rootReducer;
console
Uncaught Error: Reducer "activeBook" returned undefined during initialization. If the state passed to the reducer is undefined, you must explicitly return the initial state. The initial state may not be undefined. If you don't want to set a value for this reducer, you can use null instead of undefined.
Nevermind, I knew it was something really stupid once I changed the reducer_active_book.js file and got the same error. It was another file in the same directory named reducer_active_book (without extension) that I somehow saved and was getting pulled into the project rather than the .js file