[router] Fix false positive redirect deprecation since version 2.0.1 when using Screen #23932
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
WARN The redirect prop on is deprecated and will be removed. Please use router.redirect, fixes expo/router#834
I think issue is here perhaps https://github.com/expo/router/blob/f69e31c84a83ceb6d678dfb8aeed708974d301a8/packages/expo-router/src/views/Screen.tsx#L49
if you look at the code, if you do this for example:
Then deprecated prop would end up being
undefined
becauseredirect
would not be setThen looking at
useDepecated
code here:the
guard
would end up being set totrue
because of the default valueguard: unknown = true
How
Avoid sending an undefined
redirect
prop to the guardTest Plan
Run updated code and make sure warning is gone
Checklist
npx expo prebuild
& EAS Build (eg: updated a module plugin).