banderson / generator-redux

CLI tools for Redux: next-gen functional Flux/React with devtools
252 stars 36 forks source link

Error while open sample app: Uncaught TypeError: store.getState is not a function #17

Closed godgav closed 8 years ago

godgav commented 8 years ago

I've generated redux scaffold application and encountered an error when load initial app page

Uncaught TypeError: store.getState is not a function
computeStateProps @ bundle.js:30534Connect @ bundle.js:30598ReactCompositeComponentMixin.mountComponent @ bundle.js:16810wrapper @ bundle.js:14939ReactReconciler.mountComponent @ bundle.js:15014ReactCompositeComponentMixin.mountComponent @ bundle.js:16922wrapper @ bundle.js:14939ReactReconciler.mountComponent @ bundle.js:15014ReactMultiChild.Mixin.mountChildren @ bundle.js:22540ReactDOMComponent.Mixin._createContentMarkup @ bundle.js:22124ReactDOMComponent.Mixin.mountComponent @ bundle.js:22034ReactReconciler.mountComponent @ bundle.js:15014ReactCompositeComponentMixin.mountComponent @ bundle.js:16922wrapper @ bundle.js:14939ReactReconciler.mountComponent @ bundle.js:15014ReactCompositeComponentMixin.mountComponent @ bundle.js:16922wrapper @ bundle.js:14939ReactReconciler.mountComponent @ bundle.js:15014mountComponentIntoNode @ bundle.js:10075Mixin.perform @ bundle.js:16277batchedMountComponentIntoNode @ bundle.js:10096Mixin.perform @ bundle.js:16277ReactDefaultBatchingStrategy.batchedUpdates @ bundle.js:25525batchedUpdates @ bundle.js:15746ReactMount._renderNewRootComponent @ bundle.js:10231wrapper @ bundle.js:14939ReactMount.render @ bundle.js:10320wrapper @ bundle.js:14939(anonymous function) @ bundle.js:9405(anonymous function) @ bundle.js:9407(anonymous function) @ bundle.js:9408__webpack_require__ @ bundle.js:521fn @ bundle.js:76(anonymous function) @ bundle.js:553__webpack_require__ @ bundle.js:521(anonymous function) @ bundle.js:544(anonymous function) @ bundle.js:547
bundle.js:5685 XHR finished loading: GET "http://localhost:3000/socket.io/?EIO=3&transport=polling&t=1444205952673-0".Request.create @ bundle.js:5685Request @ bundle.js:5608XHR.request @ bundle.js:5539XHR.doPoll @ bundle.js:5569Polling.poll @ bundle.js:5962Polling.doOpen @ bundle.js:5906Transport.open @ bundle.js:6177Socket.open @ bundle.js:4816Socket @ bundle.js:4698Socket @ bundle.js:4633Manager.open.Manager.connect @ bundle.js:4268Manager @ bundle.js:4126Manager @ bundle.js:4096lookup @ bundle.js:2143(anonymous function) @ bundle.js:570(anonymous function) @ bundle.js:645__webpack_require__ @ bundle.js:521fn @ bundle.js:76(anonymous function) @ bundle.js:551__webpack_require__ @ bundle.js:521(anonymous function) @ bundle.js:544(anonymous function) @ bundle.js:547

here is generated package.json

{
  "name": "reactjs-data-table",
  "version": "0.1.0",
  "dependencies": {
    "babel-runtime": "^5.8.25",
    "lodash": "^3.10.1",
    "react": "^0.13.3",
    "react-redux": "^3.1.0",
    "redux": "^3.0.2",
    "redux-devtools": "^2.1.5",
    "redux-thunk": "^1.0.0"
  },
  "scripts": {
    "start": "DEBUG=true node server.js",
    "build": "webpack -p"
  },
  "devDependencies": {
    "babel-core": "^5.8.25",
    "babel-loader": "^5.3.2",
    "css-loader": "^0.19.0",
    "cssnext-loader": "^1.0.1",
    "extract-text-webpack-plugin": "^0.8.2",
    "jsx-loader": "^0.13.2",
    "react-hot-loader": "^1.3.0",
    "style-loader": "^0.12.4",
    "webpack": "^1.12.2",
    "webpack-dev-server": "^1.12.0"
  }
}
ramdog commented 8 years ago

Similarly, this is what I see in the browser console when I run npm start.

screen shot 2015-10-14 at 9 37 47 am

YPCrumble commented 8 years ago

:+1: has either of you figured out the quick fix to this?

idlesong commented 8 years ago

Change the configureStore.js as below can fix this.

// 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);
}
banderson commented 8 years ago

@godgav @YPCrumble @idlesong I just bumped to version 0.3.0 which should have a bunch of fixes for versioning problems across react and redux. Can you see if that latest version fixes this issue for you?

idlesong commented 8 years ago

@banderson Thanks. It's ok now.