gullmarc
gullmarc

Reputation: 1

configureStore argument is not a valid reducer

I have made sure both of my reducers work, and all imports are valid

const store = configureStore({ 
  reducer: {
    drinks: drinksReducer,
    selectedDrinks: selectedDrinksReducer
  } 
});

but this gives me the error: "Store does not have a valid reducer. Make sure the argument passed to combineReducers is an object whose values are reducers."

When i only pass in one reducer:

const store = configureStore({ reducer: drinksReducer });

the code works, but as soon as i make it an object with reducers as values, the code gives me an error. How do i fix this?

Upvotes: 2

Views: 239

Answers (1)

Leon
Leon

Reputation: 166

As it suggests, the param object has reducers as property, for multiple reducers, combineReducers can help to group them together and return another reducer. combineReducers

const store = configureStore(combineReducers({ 
    drinks: drinksReducer,
    selectedDrinks: selectedDrinksReducer
}));

Upvotes: 2

Related Questions