Here's the error:
[1] TypeError: _dispatch is not a function
[1] at Object.dispatch (/Users/thomas/Desktop/react-redux-universal-hot-example/node_modules/redux/lib/applyMiddleware.js:45:18)
[1] at /Users/thomas/Desktop/react-redux-universal-hot-example/node_modules/react-router-redux/lib/index.js:90:13
[1] at /Users/thomas/Desktop/react-redux-universal-hot-example/node_modules/history/lib/useQueries.js:109:9
[1] at /Users/thomas/Desktop/react-redux-universal-hot-example/node_modules/history/lib/useBasename.js:84:9
[1] at Object.listen (/Users/thomas/Desktop/react-redux-universal-hot-example/node_modules/history/lib/createHistory.js:104:7)
[1] at Object.listen (/Users/thomas/Desktop/react-redux-universal-hot-example/node_modules/history/lib/useBasename.js:83:22)
[1] at Object.listen (/Users/thomas/Desktop/react-redux-universal-hot-example/node_modules/history/lib/useQueries.js:108:22)
[1] at middleware (/Users/thomas/Desktop/react-redux-universal-hot-example/node_modules/react-router-redux/lib/index.js:83:34)
[1] at /Users/thomas/Desktop/react-redux-universal-hot-example/node_modules/redux/lib/applyMiddleware.js:49:16
[1] at Array.map (native)
Seems that a default value was removed in a commit (https://github.com/reactjs/redux/commit/9496fd793bac83cedb643aba8da2c164aaf52a15) 11 days ago.
This line here needs access to dispatch and it's undefined.
Here's how to recreate the error:
git clone https://github.com/erikras/react-redux-universal-hot-example.git
cd react-redux-universal-hot-example
npm install
npm run dev
To get around this for now until it is fixed, you will want to use v3.4.0 instead of v3.5.0.
The problem is react-router-redux, update version to 4.0.2 and edit your code
Updating react-router-redux didn't solve it for me. I had to revert back to 3.4.0 to get my app working.
I think there is something weird in this file:
https://github.com/reactjs/redux/blob/v3.5.0/src/applyMiddleware.js#L27
In version 3.5.0 it was changed so that line 27 can potentially call empty variable set on line 22. Even if this is intentional, it looks kinda weird to me.
This is how the file looks like after babel conversion:
function applyMiddleware() {
for (var _len = arguments.length, middlewares = Array(_len), _key = 0; _key < _len; _key++) {
middlewares[_key] = arguments[_key];
}
return function (createStore) {
return function (reducer, initialState, enhancer) {
var store = createStore(reducer, initialState, enhancer);
var _dispatch;
var chain = [];
var middlewareAPI = {
getState: store.getState,
dispatch: function dispatch(action) {
return _dispatch(action);
}
};
chain = middlewares.map(function (middleware) {
return middleware(middlewareAPI);
});
_dispatch = _compose2["default"].apply(undefined, chain)(store.dispatch);
return _extends({}, store, {
dispatch: _dispatch
});
};
};
}
Thank you very much for reporting! Fixed in 3.5.1.
also encountered this issue, working as of 3.5.1 thanks! appreciated.
encountered the same issue, upgrading to 3.5.1 fixes perfectly. thanks for the promptly reply :)
Most helpful comment
Thank you very much for reporting! Fixed in 3.5.1.