Skip to content

Commit

Permalink
fix($locationKey): get user-defined location key via locationKey() fu…
Browse files Browse the repository at this point in the history
…nction
  • Loading branch information
faceyspacey committed Jul 4, 2017
1 parent a7a63bd commit a332039
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 8 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
4 changes: 3 additions & 1 deletion src/Link.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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,
Expand Down
7 changes: 4 additions & 3 deletions src/NavLink.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand Down Expand Up @@ -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 (
Expand Down
6 changes: 3 additions & 3 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down

0 comments on commit a332039

Please # to comment.