diff --git a/packages/react-navigation/src/routers/StackRouter.js b/packages/react-navigation/src/routers/StackRouter.js index e6095aa6..9be5961e 100644 --- a/packages/react-navigation/src/routers/StackRouter.js +++ b/packages/react-navigation/src/routers/StackRouter.js @@ -137,7 +137,6 @@ export default ( const childRoute = state.routes[childIndex]; const childRouter = childRouters[childRoute.routeName]; if (childRouter) { - delete action.key; const route = childRouter.getStateForAction(action, childRoute); if (route && route !== childRoute) { return StateUtils.replaceAt(state, childRoute.key, route); diff --git a/packages/react-navigation/src/routers/__tests__/StackRouter-test.js b/packages/react-navigation/src/routers/__tests__/StackRouter-test.js index 52b1f9d7..cba583ae 100644 --- a/packages/react-navigation/src/routers/__tests__/StackRouter-test.js +++ b/packages/react-navigation/src/routers/__tests__/StackRouter-test.js @@ -467,6 +467,38 @@ describe('StackRouter', () => { expect(state2 && state2.routes[0].params).toEqual({ name: 'Qux' }); }); + test('Handles the setParams action with nested routers', () => { + const ChildNavigator = () =>
; + const GrandChildNavigator = () =>
; + GrandChildNavigator.router = StackRouter({ + Quux: { screen: () =>
, }, + Corge: { screen: () =>
, }, + }); + ChildNavigator.router = TabRouter({ + Baz: { screen: GrandChildNavigator, }, + Qux: { screen: () =>
, }, + }); + const router = StackRouter({ + Foo: { screen: ChildNavigator, }, + Bar: { screen: () =>
, }, + }); + const state = router.getStateForAction({ type: NavigationActions.INIT }); + const state2 = router.getStateForAction({ + type: NavigationActions.SET_PARAMS, + params: { name: 'foobar' }, + key: 'Init', + }, state); + expect(state2 && state2.index).toEqual(0); + /* $FlowFixMe */ + expect(state2 && state2.routes[0].routes[0].routes).toEqual([ + { + key: 'Init', + routeName: 'Quux', + params: { name: 'foobar' }, + }, + ]); + }); + test('Handles the reset action', () => { const router = StackRouter({ Foo: {