File tree 1 file changed +14
-0
lines changed
1 file changed +14
-0
lines changed Original file line number Diff line number Diff line change 1
1
import createHashHistory from 'history/lib/createHashHistory'
2
2
import useQueries from 'history/lib/useQueries'
3
+ import invariant from 'invariant'
3
4
import React from 'react'
4
5
5
6
import createTransitionManager from './createTransitionManager'
@@ -13,6 +14,12 @@ function isDeprecatedHistory(history) {
13
14
return ! history || ! history . __v2_compatible__
14
15
}
15
16
17
+ /* istanbul ignore next: sanity check */
18
+ function isUnsupportedHistory ( history ) {
19
+ // v3 histories expose getCurrentLocation, but aren't currently supported.
20
+ return history && history . getCurrentLocation
21
+ }
22
+
16
23
const { func, object } = React . PropTypes
17
24
18
25
/**
@@ -91,6 +98,13 @@ const Router = React.createClass({
91
98
let { history } = this . props
92
99
const { routes, children } = this . props
93
100
101
+ invariant (
102
+ ! isUnsupportedHistory ( history ) ,
103
+ 'You have provided a history object from created with history v3.x. ' +
104
+ 'This version of React Router is not compatible with v3 history ' +
105
+ 'objects. Please use history v2.x instead.'
106
+ )
107
+
94
108
if ( isDeprecatedHistory ( history ) ) {
95
109
history = this . wrapDeprecatedHistory ( history )
96
110
}
You can’t perform that action at this time.
0 commit comments