Reputation: 2187
I am using the generator from https://github.com/stylesuxx/generator-react-webpack-redux. The development is going fine except that I have an error in browser console
warning.js:10 Store does not have a valid reducer. Make sure the argument passed to combineReducers is an object whose values are reducers.
In index.js
in reduces file, the code is stated below:
import { combineReducers } from 'redux';
const reducers = {};
const combined = combineReducers(reducers);
module.exports = combined;
In index.js
in stores file, the code is stated below:
import { createStore } from 'redux';
import reducers from '../reducers';
function reduxStore(initialState) {
const store = createStore(reducers, initialState,
window.devToolsExtension && window.devToolsExtension());
if (module.hot) {
// Enable Webpack hot module replacement for reducers
module.hot.accept('../reducers', () => {
// We need to require for hot reloading to work properly.
const nextReducer = require('../reducers'); // eslint-disable-line global-require
store.replaceReducer(nextReducer);
});
}
return store;
}
export default reduxStore;
I am not using redux in current development but I use the generator for configuration there for future planning. Any idea how to make the reducer empty like the code above const reducers = {};
without triggering any warning?
Upvotes: 0
Views: 1007
Reputation: 1182
Why don't you try to create a function instead of an empty object?
According to redux documentation it should be a function:
reducer (Function): A reducing function that returns the next state tree, given the current state tree and an action to handle. https://github.com/reactjs/redux/blob/master/docs/api/createStore.md
Also I don't know if you need to use combinereducers
as you only have one.
Upvotes: 0
Reputation: 909
What you need is a valid reducer as the error suggest. either you can try the following if you want to keep the boilerplate or
const reducers = { somename: () => {} };
const combined = combineReducers(reducers);
module.exports = combined;
or try
module.exports = () => {};
this will make sure a valid reducer function is returned. since you are not using redux this will not be a problem.
Upvotes: 1