mirror of
https://github.com/zhigang1992/react-navigation.git
synced 2026-01-12 22:51:18 +08:00
fix: fix nested navigation not working the first time
This commit is contained in:
@@ -747,7 +747,7 @@ it('navigates to nested child in a navigator', () => {
|
||||
act(() => navigation.current?.navigate('bar', { screen: 'bar-b' }));
|
||||
|
||||
expect(element).toMatchInlineSnapshot(
|
||||
`"[bar-b, {\\"some\\":\\"stuff\\",\\"test\\":42}]"`
|
||||
`"[bar-b, {\\"some\\":\\"stuff\\",\\"test\\":42,\\"whoa\\":\\"test\\"}]"`
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
@@ -356,21 +356,8 @@ export default function useNavigationBuilder<
|
||||
route.params !== previousParams)
|
||||
) {
|
||||
// FIXME: Since params are merged, `route.params.params` might contain params from an older route
|
||||
// So we need to make sure to reuse it only if:
|
||||
// - The screen is the same, so navigation happened with same params
|
||||
// - Params have actually changed
|
||||
// - It's the first navigation during initialization
|
||||
const params = (
|
||||
route.params.screen === nextState.routes[nextState.index].name
|
||||
? route.params.screen === previousParams?.screen
|
||||
: route.params.params !== previousParams?.params ||
|
||||
(route.params.initial === false && isFirstStateInitialization)
|
||||
)
|
||||
? route.params.params
|
||||
: undefined;
|
||||
|
||||
// If the route was updated with new screen name and/or params, we should navigate there
|
||||
action = CommonActions.navigate(route.params.screen, params);
|
||||
action = CommonActions.navigate(route.params.screen, route.params.params);
|
||||
}
|
||||
|
||||
// The update should be limited to current navigator only, so we call the router manually
|
||||
|
||||
Reference in New Issue
Block a user