Skip to content

Commit

Permalink
Throw instead of silently failing with history v3 (#3571)
Browse files Browse the repository at this point in the history
  • Loading branch information
taion authored and timdorr committed Jun 23, 2016
1 parent 4e24ae7 commit 44b3c6e
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions modules/Router.js
@@ -1,5 +1,6 @@
import createHashHistory from 'history/lib/createHashHistory'
import useQueries from 'history/lib/useQueries'
import invariant from 'invariant'
import React from 'react'

import createTransitionManager from './createTransitionManager'
Expand All @@ -13,6 +14,12 @@ function isDeprecatedHistory(history) {
return !history || !history.__v2_compatible__
}

/* istanbul ignore next: sanity check */
function isUnsupportedHistory(history) {
// v3 histories expose getCurrentLocation, but aren't currently supported.
return history && history.getCurrentLocation
}

const { func, object } = React.PropTypes

/**
Expand Down Expand Up @@ -91,6 +98,13 @@ const Router = React.createClass({
let { history } = this.props
const { routes, children } = this.props

invariant(
!isUnsupportedHistory(history),
'You have provided a history object from created with history v3.x. ' +
'This version of React Router is not compatible with v3 history ' +
'objects. Please use history v2.x instead.'
)

if (isDeprecatedHistory(history)) {
history = this.wrapDeprecatedHistory(history)
}
Expand Down

0 comments on commit 44b3c6e

Please sign in to comment.