Reputation: 7971
The redux getState
method is not available. Do I need any middleware for achieving the desired result. Following is the code
const configureStore = (initialState = {}) => {
return createStore(
rootReducer,
initialState,
applyMiddleware(...middleware),
);
};
export default configureStore;
util.js
import store from '../../store';
store.getState()
// _store2.default.getState is not a function
Upvotes: 0
Views: 382
Reputation: 9448
Looks like you intended to, at some point, initialize the store.
I'm not sure how you want to layout your app, but
// index.js
import configureStore from 'store';
export const store = configureStore({ ... someInitialState });
then
// util.js
import store from 'index';
// use store
I don't think this is the best solution - instead of exporting an store initializer from store
, just initialize the store and export the store.
Upvotes: 0
Reputation: 3518
You are returning a function instead of your store. Seems like you have mixed up reducers with the store. What you want is this:
const store = createStore(
rootReducer,
initialState,
applyMiddleware(...middleware),
);
export default store;
Upvotes: 4