Reputation: 11
store does not have a valid reducer. Make sure the argument passed to combineReducers is an object whose values are reducers,
Here My store and root reducer file
import { createStore, applyMiddleware } from "redux";
import logger from "redux-logger";
import rootReducer from "./rootReducer";
const middlewares = [logger];
const store = createStore(rootReducer);
export default store;
This is the first time I'm working with React and Redux. I haven't been able to find error around it.
the above code is a total redux setup please help why this error coming:
import { combineReducers } from "redux";
import cardReducer from "../Services/profileimages/reducer";
export default combineReducers(cardReducer);
and my reducer file
import initialState from "./initialState";
import * as types from "./actionTypes";
const cardReducer = ({ state = initialState, action }) => {
switch (action.type) {
case types.FIREBASE_GETTING_IMAGES:
return {
cards: action.cards,
};
default:
return state;
}
};
export default cardReducer;
Haven't been able to find anything around here regarding this error:
import initialState from "./initialState";
import * as types from "./actionTypes";
const cardReducer = ({ state = initialState, action }) => {
switch (action.type) {
case types.FIREBASE_GETTING_IMAGES:
return {
cards: action.cards,
};
default:
return state;
}
};
export default cardReducer;
the above code is a total redux setup please help why this error coming
Upvotes: 1
Views: 3854
Reputation: 102237
From the API doc combineReducers(reducers), the reducers
parameter should be
An object whose values correspond to different reducing functions that need to be combined into one. See the notes below for some rules every passed reducer must follow.
Therefore, the correct usage is:
import { combineReducers } from 'redux';
import cardReducer from './cardReducer';
export default combineReducers({
card: cardReducer,
});
Besides, the cardReducer
has the wrong signature. It should be:
const cardReducer = (state = initialState, action) {}
Upvotes: 2