Uncaught TypeError: store.getState is not a function
windyboy opened this issue · comments
I just create a empty app with 'yo redux'
Got error message from dev console.
Got the same problem. if you start the server without the debug flag it works.
for example: node server.js
This is actually still an issue because redux devTools have changed a bit. I will submit PR with update
Yeah, I just noticed this today, updating to redux v3.0.0, react-redux 3.0.0, and redux-devtools 2.1.3
Was hoping to give Redux a try using you generator and am stuck here, not sure the solution as I'm not familiar enough with Redux.
what does your configureStore.js
file look like?
import {createStore, applyMiddleware, combineReducers, compose} from 'redux';
import thunkMiddleware from 'redux-thunk';
import * as reducers from '../reducers/index';
let createStoreWithMiddleware;
// Configure the dev tools when in DEV mode
if (__DEV__) {
let {devTools, persistState} = require('redux-devtools');
createStoreWithMiddleware = compose(
applyMiddleware(thunkMiddleware),
devTools(),
persistState(window.location.href.match(/[?&]debug_session=([^&]+)\b/)),
createStore
);
} else {
createStoreWithMiddleware = applyMiddleware(thunkMiddleware)(createStore);
}
const rootReducer = combineReducers(reducers);
export default function configureStore(initialState) {
return createStoreWithMiddleware(rootReducer, initialState);
}
I encountered the same issue, and found the fix referenced by @pdf worked for me, so on the above, change..
createStoreWithMiddleware = compose(
applyMiddleware(thunkMiddleware),
devTools(),
persistState(window.location.href.match(/[?&]debug_session=([^&]+)\b/)),
createStore
);
to be..
createStoreWithMiddleware = compose(
applyMiddleware(thunkMiddleware),
devTools(),
persistState(window.location.href.match(/[?&]debug_session=([^&]+)\b/))
)(createStore);
@thatguynamedandy : thank you.
I'm getting this error with a redux boilerplate project. The simplest possible correct case (without devtools etc etc) should be:
const createStoreWithMiddleware = applyMiddleware(thunkMiddleware)(createStore);
export default function configureStore(initialState) {
return createStoreWithMiddleware(rootReducer, initialState);
}
however, TypeError: store.getState is not a function
comes up
appreciate any help!
"connected-react-router": "^6.2.2",
"history": "^4.7.2",
"react": "^16.7.0",
"react-dom": "^16.7.0",
"react-redux": "^6.0.0",
"react-router-dom": "^4.3.1",
"redux": "^4.0.1",
"redux-thunk": "^2.3.0",
"body-parser": "^1.17.1",
"react-router": "^4.3.1",