diff --git a/package.json b/package.json index 350272d..e05c097 100644 --- a/package.json +++ b/package.json @@ -64,7 +64,7 @@ "react-redux": "^5.x", "react-test-renderer": "^15.5.4", "redux": "^3.x", - "redux-first-router": "^1.7.3", + "redux-first-router": "^1.7.4", "rimraf": "^2.5.4", "semantic-release": "^6.3.2", "travis-github-status": "^1.6.2", diff --git a/src/Link.js b/src/Link.js index 71ba8e5..13c5c65 100644 --- a/src/Link.js +++ b/src/Link.js @@ -5,6 +5,7 @@ import PropTypes from 'prop-types' import { connect } from 'react-redux' import type { Store } from 'redux' import type { Connector } from 'react-redux' +import { locationKey } from 'redux-first-router' import toUrl from './toUrl' import handlePress from './handlePress' @@ -44,7 +45,8 @@ export const Link = ( ) => { to = href || to // href is deprecated and will be removed in next major version - const { routesMap } = store.getState().location + const location = store.getState()[locationKey()] + const { routesMap } = location const url = toUrl(to, routesMap) const handler = handlePress.bind( null, diff --git a/src/NavLink.js b/src/NavLink.js index a4bf3e0..971712e 100644 --- a/src/NavLink.js +++ b/src/NavLink.js @@ -6,9 +6,10 @@ import { connect } from 'react-redux' import type { Store } from 'redux' import type { Connector } from 'react-redux' import matchPath from 'rudy-match-path' +import { locationKey } from 'redux-first-router' + import { Link } from './Link' import toUrl from './toUrl' - import type { To } from './toUrl' import type { OnClick } from './handlePress' @@ -49,9 +50,9 @@ const NavLink = ( { store }: Context ) => { to = href || to - const { location } = store.getState() - const path = toUrl(to, location.routesMap) + const location = store.getState()[locationKey()] + const path = toUrl(to, location.routesMap) const match = matchPath(pathname, { path, exact, strict }) const active = !!(isActive ? isActive(match, location) : match) return ( diff --git a/yarn.lock b/yarn.lock index b2bd949..0a2a441 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4783,9 +4783,9 @@ redent@^1.0.0: indent-string "^2.1.0" strip-indent "^1.0.1" -redux-first-router@^1.7.3: - version "1.7.3" - resolved "https://registry.yarnpkg.com/redux-first-router/-/redux-first-router-1.7.3.tgz#260adcbed49b2b34ad370ef8857ea662ca9ea272" +redux-first-router@^1.7.4: + version "1.7.4" + resolved "https://registry.yarnpkg.com/redux-first-router/-/redux-first-router-1.7.4.tgz#79169512b35d9bc46b72f5cbd95b3894f35675a0" dependencies: path-to-regexp "^1.7.0"