Skip to content

Commit 7c3b469

Browse files
committed
Pass location and params in context
1 parent dcb1b51 commit 7c3b469

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

modules/Router.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ const Router = React.createClass({
6262
if (error) {
6363
this.handleError(error)
6464
} else {
65+
router.location = state.location
66+
router.params = state.params
6567
this.setState(state, this.props.onUpdate)
6668
}
6769
})
@@ -82,7 +84,10 @@ const Router = React.createClass({
8284
history,
8385
createRoutes(routes || children)
8486
)
87+
8588
const router = createRouterObject(history, transitionManager)
89+
router.location = null
90+
router.params = null
8691

8792
return { transitionManager, router }
8893
},

modules/__tests__/Router-test.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,12 @@ describe('Router', function () {
297297
const assertProps = (props) => {
298298
expect(props.routes).toEqual([ route ])
299299
expect(props.components).toEqual([ MyComponent ])
300+
301+
expect(props.params).toEqual({})
302+
expect(props.location.pathname).toEqual('/')
303+
expect(props.router.params).toEqual({})
304+
expect(props.router.location.pathname).toEqual('/')
305+
300306
expect(props.foo).toBe('bar')
301307
expect(props.render).toNotExist()
302308
done()

0 commit comments

Comments
 (0)