-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[router]: include search parameters in the default Screen.getId() #26710
Conversation
* fall back to `key` based navigation. This is an issue for search parameters where are either | ||
* part of the key or the id. | ||
*/ | ||
return id || route.contextKey; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We now always return an ID value. This prevents React Navigation from falling back to name
& key
based matching, where it may match on a correct key
, but this screen may have had parameters.
expect(testRouter.canGoBack()).toBe(false); | ||
}); | ||
|
||
it.skip('handles popToTop', async () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't have popToTop
on the router?. I'll add it in a new PR
Co-authored-by: Expo Bot <34669131+expo-bot@users.noreply.github.com>
64b2922
to
dc0e369
Compare
Related #26916 |
b0bee6c
to
51dc0f9
Compare
# Why Fix: #26669 Close: #26597 # How #26597 correctly identified that we need to deep compare the `params`. I cleaned up the logic and added unit tests which are a minimal reproduction of #26669 # Test Plan The `navigation.test.ios.tsx` file is getting a bit messy, so I created a new `push.test.ios.tsx` file. Over time I'm going to separate the rest of the `navigation` tests into a `push`/`navigate`/`replace` files. See comments for more information # Blocked by #26710 - Screens with search parameters are being incorrectly handled PR pending - Screens are not being hoisted correctly. This causes the `push` to behave incorrectly as the screen is not within the expected `_layout` # Checklist <!-- Please check the appropriate items below if they apply to your diff. This is required for changes to Expo modules. --> - [ ] Documentation is up to date to reflect these changes (eg: https://docs.expo.dev and README.md). - [ ] Conforms with the [Documentation Writing Style Guide](https://github.com/expo/expo/blob/main/guides/Expo%20Documentation%20Writing%20Style%20Guide.md) - [ ] This diff will work correctly for `npx expo prebuild` & EAS Build (eg: updated a module plugin). --------- Co-authored-by: kennethstarkrl <kenneth@feednom.com>
Why
push
/navigate
/replace
don't work as expected with search parameters. React Navigation uses both the screen's name & ID to detect if the screen is within the stack. If the search parameters are not included in the ID then React Navigation will treat/test?a=true === /test?b=true
How
I've rewritten the
createGetIdForRoute
with annotations below. There are two main differences_layout
is the same).Test Plan
I've adjusted the existing
getId
tests. All our testing tests still pass, but this is mostly due to lack of coverage.Checklist
npx expo prebuild
& EAS Build (eg: updated a module plugin).