Skip to content

Commit 4bd17f3

Browse files
committed
Make StaticRouter inheritence work
1 parent fdec57f commit 4bd17f3

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

packages/react-router/modules/Router.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,7 @@ import RouterContext from "./RouterContext";
1010
class Router extends React.Component {
1111
static propTypes = {
1212
history: PropTypes.object.isRequired,
13-
children: PropTypes.node
14-
};
15-
16-
static contextTypes = {
13+
children: PropTypes.node,
1714
router: PropTypes.object
1815
};
1916

@@ -24,7 +21,7 @@ class Router extends React.Component {
2421
getChildContext() {
2522
return {
2623
router: {
27-
...this.context.router,
24+
...this.props.router,
2825
history: this.props.history,
2926
route: {
3027
location: this.props.history.location,

packages/react-router/modules/StaticRouter.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,13 @@ class StaticRouter extends React.Component {
114114
block: this.handleBlock
115115
};
116116

117-
return <Router {...props} history={history} />;
117+
return (
118+
<Router
119+
{...props}
120+
history={history}
121+
router={this.getChildContext().router}
122+
/>
123+
);
118124
}
119125
}
120126

0 commit comments

Comments
 (0)