Skip to content

Commit a9a7f00

Browse files
committed
Revert changes made to Router.js in 361e1b5
Now people using DevTools won't see an extra <Route> in the hierarchy.
1 parent 7618254 commit a9a7f00

File tree

1 file changed

+23
-9
lines changed

1 file changed

+23
-9
lines changed

packages/react-router/modules/Router.js

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import warning from 'warning'
22
import invariant from 'invariant'
3-
import Route from './Route'
43
import React, { PropTypes } from 'react'
54

65
/**
@@ -13,12 +12,29 @@ class Router extends React.Component {
1312
}
1413

1514
static childContextTypes = {
16-
history: PropTypes.object.isRequired
15+
history: PropTypes.object.isRequired,
16+
route: PropTypes.object.isRequired
1717
}
1818

1919
getChildContext() {
2020
return {
21-
history: this.props.history
21+
history: this.props.history,
22+
route: {
23+
match: this.state.match
24+
}
25+
}
26+
}
27+
28+
state = {
29+
match: this.computeMatch(this.props.history.location.pathname)
30+
}
31+
32+
computeMatch(pathname) {
33+
return {
34+
path: '/',
35+
url: '/',
36+
params: {},
37+
isExact: pathname === '/'
2238
}
2339
}
2440

@@ -34,7 +50,9 @@ class Router extends React.Component {
3450
// location in componentWillMount. This happens e.g. when doing
3551
// server rendering using a <StaticRouter>.
3652
this.unlisten = history.listen(() => {
37-
this.forceUpdate()
53+
this.setState({
54+
match: this.computeMatch(history.location.pathname)
55+
})
3856
})
3957
}
4058

@@ -51,11 +69,7 @@ class Router extends React.Component {
5169

5270
render() {
5371
const { children } = this.props
54-
return children ? (
55-
<Route path="/" render={() => (
56-
React.Children.only(children)
57-
)}/>
58-
) : null
72+
return children ? React.Children.only(children) : null
5973
}
6074
}
6175

0 commit comments

Comments
 (0)