Skip to content
This repository has been archived by the owner on May 17, 2019. It is now read-only.

Fix issue #28: cannot read property 'pathname' of undefined #29

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,17 @@
"react-redux": "^5.1.1"
},
"peerDependencies": {
"connected-react-router": "^4.4.1",
"connected-react-router": "^5.0.1",
"fusion-core": "^1.10.1",
"fusion-plugin-react-router": "^1.2.0-0",
"fusion-plugin-react-router": "^1.5.0",
"react": "14.x - 16.x",
"react-dom": "14.x - 16.x",
"redux": "^4.0.0"
},
"devDependencies": {
"@babel/preset-react": "^7.0.0-rc.1",
"babel-eslint": "10.0.1",
"connected-react-router": "^4.4.1",
"connected-react-router": "^5.0.1",
"create-universal-package": "3.4.6",
"eslint": "5.13.0",
"eslint-config-fusion": "^4.0.0",
Expand All @@ -48,7 +48,7 @@
"eslint-plugin-react": "7.11.1",
"flow-bin": "^0.91.0",
"fusion-core": "^1.10.0",
"fusion-plugin-react-router": "1.4.2",
"fusion-plugin-react-router": "^1.5.0",
"fusion-plugin-universal-events": "^1.3.0",
"fusion-react": "^1.3.7",
"fusion-test-utils": "^1.3.0",
Expand Down
12 changes: 12 additions & 0 deletions src/flatCombineReducers.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// @flow
import type {Reducer} from 'redux';

function flatCombineReducers(...reducers: Array<Reducer<Object, Object>>): Reducer<Object, Object> {
return (state: Object | void, action: Object) => {
return reducers.reduce((newState: Object, reducer: Reducer<Object, Object>): Object => {
return {...newState, ...reducer(newState, action)};
}, state);
};
}

export default flatCombineReducers;
6 changes: 4 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,16 @@
*
* @flow
*/

import {createPlugin} from 'fusion-core';

import {combineReducers} from 'redux';
import {
routerMiddleware as createRouterMiddleware,
connectRouter,
} from 'connected-react-router';
import {RouterToken} from 'fusion-plugin-react-router';

import flatCombineReducers from './flatCombineReducers';
import type {ConnectedRouterPluginType} from './types';

const plugin: ConnectedRouterPluginType = createPlugin({
Expand All @@ -26,7 +27,8 @@ const plugin: ConnectedRouterPluginType = createPlugin({
const store = createStore(reducer, initialState);
// $FlowFixMe - We enhance the store to add ctx onto it, which doesn't exist in the redux libdef
const {history} = router.from(store.ctx);
store.replaceReducer(connectRouter(history)(reducer));
const routerReducer = combineReducers({router: connectRouter(history)});
store.replaceReducer(flatCombineReducers(reducer, routerReducer));
const oldDispatch = store.dispatch;
const routerMiddleware = createRouterMiddleware(history)(store);
store.dispatch = action => {
Expand Down
34 changes: 7 additions & 27 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1188,7 +1188,6 @@ caching-transform@^2.0.0:
callsites@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/callsites/-/callsites-3.0.0.tgz#fb7eb569b72ad7a45812f93fd9430a3e410b3dd3"
integrity sha512-tWnkwu9YEq2uzlBDI4RcLn8jrFvF9AOi8PxDNU3hZZjJcjkcRAq3vCI+vZcg1SuxISDYe86k9VZFwAxDiJGoAw==

[email protected]:
version "5.0.0"
Expand Down Expand Up @@ -1384,12 +1383,11 @@ [email protected]:
version "0.0.1"
resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b"

connected-react-router@^4.4.1:
version "4.5.0"
resolved "https://registry.yarnpkg.com/connected-react-router/-/connected-react-router-4.5.0.tgz#b6f021cc284a244fbee70e16e5ff0f2a4613e3d3"
connected-react-router@^5.0.1:
version "5.0.1"
resolved "https://registry.yarnpkg.com/connected-react-router/-/connected-react-router-5.0.1.tgz#8379854fad7e027b1e27652c00ad534f8ad244b3"
dependencies:
immutable "^3.8.1"
redux-seamless-immutable "^0.4.0"
seamless-immutable "^7.1.3"

console-browserify@^1.1.0:
Expand Down Expand Up @@ -1890,7 +1888,6 @@ eslint-module-utils@^2.2.0:
[email protected]:
version "2.0.1"
resolved "https://registry.yarnpkg.com/eslint-plugin-cup/-/eslint-plugin-cup-2.0.1.tgz#dab2827e722404fb590209321538c82226e2c08d"
integrity sha512-mQiZ6Wd/LWnSDQ/jhJb7t92MeWBW2x9T1F8QJttIDKvW/1Moedor3tbSMPGu+hhT8m8OL+egvBy6/sslcnQsqw==
dependencies:
globals "^11.5.0"

Expand Down Expand Up @@ -1964,7 +1961,6 @@ eslint-visitor-keys@^1.0.0:
[email protected]:
version "5.13.0"
resolved "https://registry.yarnpkg.com/eslint/-/eslint-5.13.0.tgz#ce71cc529c450eed9504530939aa97527861ede9"
integrity sha512-nqD5WQMisciZC5EHZowejLKQjWGuFS5c70fxqSKlnDME+oz9zmE8KTlX+lHSg+/5wsC/kf9Q9eMkC8qS3oM2fg==
dependencies:
"@babel/code-frame" "^7.0.0"
ajv "^6.5.3"
Expand Down Expand Up @@ -2237,7 +2233,6 @@ flat-cache@^1.2.1:
flow-bin@^0.91.0:
version "0.91.0"
resolved "https://registry.yarnpkg.com/flow-bin/-/flow-bin-0.91.0.tgz#f5c89729f74b2ccbd47df6fbfadbdcc89cc1e478"
integrity sha512-j+L+xNiUYnZZ27MjVI0y2c9474ZHOvdSQq0Tjwh56mEA7tfxYqp5Dcb6aZSwvs3tGMTjCrZow9aUlZf3OoRyDQ==

for-each@~0.3.3:
version "0.3.3"
Expand Down Expand Up @@ -2318,9 +2313,9 @@ fusion-plugin-react-redux@^1.0.11:
dependencies:
eslint-plugin-jest "^21.24.1"

fusion-plugin-react-router@1.4.2:
version "1.4.2"
resolved "https://registry.yarnpkg.com/fusion-plugin-react-router/-/fusion-plugin-react-router-1.4.2.tgz#78ef98a5cb61a49a42f209f171971e3660b5ec04"
fusion-plugin-react-router@^1.5.0:
version "1.5.1"
resolved "https://registry.yarnpkg.com/fusion-plugin-react-router/-/fusion-plugin-react-router-1.5.1.tgz#7f84c44001942bad08bdaa8d8d1b3f9f72ea1a78"
dependencies:
history "^4.7.2"
prop-types "^15.6.2"
Expand All @@ -2335,7 +2330,6 @@ fusion-plugin-universal-events@^1.3.0:
fusion-react@^1.3.7:
version "1.3.7"
resolved "https://registry.yarnpkg.com/fusion-react/-/fusion-react-1.3.7.tgz#7ece897feff9ef67c33f13f376929fd5a1e471f6"
integrity sha512-Zs60GxwkjEkDb2jqcdxnWmGDxUDtD8VJmT6ipnr66oXQHSDl3iMtUDQIXFFg9mZG6jeRFF+BAK1Bhf3SMKt2PQ==
dependencies:
prop-types "^15.6.2"
react-is "^16.7.0"
Expand Down Expand Up @@ -2641,7 +2635,6 @@ immutable@^3.8.1:
import-fresh@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/import-fresh/-/import-fresh-3.0.0.tgz#a3d897f420cab0e671236897f75bc14b4885c390"
integrity sha512-pOnA9tfM3Uwics+SaBLCNyZZZbK+4PTu0OPZtLlMIrv17EdBoC15S9Kn8ckJ9TZTyKb3ywNE5y1yeDxxGA7nTQ==
dependencies:
parent-module "^1.0.0"
resolve-from "^4.0.0"
Expand Down Expand Up @@ -3850,7 +3843,6 @@ pako@~1.0.5:
parent-module@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/parent-module/-/parent-module-1.0.0.tgz#df250bdc5391f4a085fb589dad761f5ad6b865b5"
integrity sha512-8Mf5juOMmiE4FcmzYc4IaiS9L3+9paz2KOiXzkRviCP6aDmN49Hz6EMWz0lGNp9pX80GvvAuLADtyGfW/Em3TA==
dependencies:
callsites "^3.0.0"

Expand Down Expand Up @@ -4137,7 +4129,6 @@ react-is@^16.3.2, react-is@^16.6.0:
react-is@^16.7.0:
version "16.7.0"
resolved "https://registry.yarnpkg.com/react-is/-/react-is-16.7.0.tgz#c1bd21c64f1f1364c6f70695ec02d69392f41bfa"
integrity sha512-Z0VRQdF4NPDoI0tsXVMLkJLiwEBa+RP66g0xDHxgxysxSoCUccSten4RTF/UFvZF1dZvZ9Zu1sx+MDXwcOR34g==

react-lifecycles-compat@^3.0.0:
version "3.0.4"
Expand Down Expand Up @@ -4166,10 +4157,6 @@ react-router-dom@^4.3.1:
react-router "^4.3.1"
warning "^4.0.1"

react-router-redux@^4.0.0:
version "4.0.8"
resolved "https://registry.yarnpkg.com/react-router-redux/-/react-router-redux-4.0.8.tgz#227403596b5151e182377dab835b5d45f0f8054e"

react-router@^4.3.1:
version "4.3.1"
resolved "https://registry.yarnpkg.com/react-router/-/react-router-4.3.1.tgz#aada4aef14c809cb2e686b05cee4742234506c4e"
Expand Down Expand Up @@ -4241,13 +4228,6 @@ readdirp@^2.0.0:
micromatch "^3.1.10"
readable-stream "^2.0.2"

redux-seamless-immutable@^0.4.0:
version "0.4.0"
resolved "https://registry.yarnpkg.com/redux-seamless-immutable/-/redux-seamless-immutable-0.4.0.tgz#b50f8680ecc5ef04021551267f78fa1ffd3cf985"
dependencies:
react-router-redux "^4.0.0"
seamless-immutable "^7.1.2"

redux@^4.0.0:
version "4.0.1"
resolved "https://registry.yarnpkg.com/redux/-/redux-4.0.1.tgz#436cae6cc40fbe4727689d7c8fae44808f1bfef5"
Expand Down Expand Up @@ -4465,7 +4445,7 @@ scheduler@^0.11.2:
loose-envify "^1.1.0"
object-assign "^4.1.1"

seamless-immutable@^7.1.2, seamless-immutable@^7.1.3:
seamless-immutable@^7.1.3:
version "7.1.4"
resolved "https://registry.yarnpkg.com/seamless-immutable/-/seamless-immutable-7.1.4.tgz#6e9536def083ddc4dea0207d722e0e80d0f372f8"

Expand Down