-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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] remove search parameters from screen.getId() #27285
Merged
marklawlor
merged 10 commits into
main
from
marklawlor/router/remove-searchparams-from-navigate
Mar 1, 2024
Merged
[router] remove search parameters from screen.getId() #27285
marklawlor
merged 10 commits into
main
from
marklawlor/router/remove-searchparams-from-navigate
Mar 1, 2024
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
marklawlor
requested review from
Simek,
amandeepmittal and
EvanBacon
as code owners
February 26, 2024 05:24
marklawlor
changed the title
(router) remove search parameters from screen getId()
(router) remove search parameters from screen.getId()
Feb 26, 2024
expo-bot
added
bot: passed checks
ExpoBot has nothing to complain about
and removed
bot: suggestions
ExpoBot has some suggestions
labels
Feb 26, 2024
marklawlor
changed the title
(router) remove search parameters from screen.getId()
[router] remove search parameters from screen.getId()
Feb 26, 2024
EvanBacon
reviewed
Feb 26, 2024
act(() => router.push('/c')); | ||
act(() => router.push('/a')); // This will unwind the stack | ||
|
||
expect(router.canGoBack()).toBe(true); // |
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.
Should check the expected history too
EvanBacon
reviewed
Feb 26, 2024
EvanBacon
reviewed
Feb 26, 2024
EvanBacon
reviewed
Feb 26, 2024
marklawlor
force-pushed
the
marklawlor/router/remove-searchparams-from-navigate
branch
from
February 27, 2024 01:34
d419cc8
to
6237433
Compare
3 tasks
Co-authored-by: Expo Bot <34669131+expo-bot@users.noreply.github.com>
Co-authored-by: Aman Mittal <amandeepmittal@live.com>
Co-authored-by: Aman Mittal <amandeepmittal@live.com>
Co-authored-by: Aman Mittal <amandeepmittal@live.com>
Co-authored-by: Evan Bacon <bacon@expo.io>
Co-authored-by: Evan Bacon <bacon@expo.io>
Co-authored-by: Evan Bacon <bacon@expo.io>
marklawlor
force-pushed
the
marklawlor/router/remove-searchparams-from-navigate
branch
from
February 28, 2024 23:50
7e6e8d6
to
1b4b362
Compare
amandeepmittal
approved these changes
Feb 29, 2024
EvanBacon
approved these changes
Feb 29, 2024
marklawlor
deleted the
marklawlor/router/remove-searchparams-from-navigate
branch
March 1, 2024 00:25
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
bot: fingerprint compatible
bot: passed checks
ExpoBot has nothing to complain about
published
Changes from the PR have been published to npm
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Why
Expo Router's
navigate
andpush
functions don't always behave as expected and have overlapping functionality. E.gpush
wouldn't always push, andnavigate
's behaviour would change based upon this history in unexpected ways.For example, lets say we are on the initial URL
/page
/page?b=1
skippedThe reason for this behaviour is that RN doesn't preserve the IDs for every screen in the history. It compares them with the current params. The
getID
function for/page?b=1
and/page
are the same, hence this behaviour.To change how React Navigation does this, we would need to fork the StackNavigator
How
The simple fix is to not include search parameters in the ID generation. This also has the advantage that is now easier to document the differences between
push
andnavigate
.After this PR, Expo Router will have this behaviour
Test Plan
I've updated the unit tests and also added a new set to test stack unwinding.
Checklist
npx expo prebuild
& EAS Build (eg: updated a module plugin).