Skip to content

Commit c70e4f3

Browse files
committed
Make StaticRouter inheritence work
1 parent f1fd566 commit c70e4f3

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
@@ -129,7 +129,13 @@ class StaticRouter extends React.Component {
129129
block: this.handleBlock
130130
};
131131

132-
return <Router {...props} history={history} />;
132+
return (
133+
<Router
134+
{...props}
135+
history={history}
136+
router={this.getChildContext().router}
137+
/>
138+
);
133139
}
134140
}
135141

0 commit comments

Comments
 (0)