Skip to content
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

fix(ENG-9886): deprecated false positive #859

Merged
merged 1 commit into from
Oct 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion packages/expo-router/src/useDeprecated.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export function useWarnOnce(
key = message
) {
// useLayoutEffect typically doesn't run in node environments.
// Combined with skipWarn, this should prevent unwanted warnings
// Combined with skipWarn, this should prevent unwanted warnings during SSR rendering
useLayoutEffect(() => {
if (guard && canWarn && !warned.has(key)) {
warned.add(key);
Expand All @@ -27,8 +27,11 @@ export function useWarnOnce(
}

export function useDeprecated(
/** The deprecated message to display */
message: string,
/** The guard to cause the warning to being displayed */
guard: unknown = true,
/** The key to use for the warning. Used to detect if the warning has already been shown. */
key = message
) {
return useWarnOnce(key, guard, `Expo Router: ${message}`);
Expand Down
2 changes: 1 addition & 1 deletion packages/expo-router/src/views/Screen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export function Screen<TOptions extends object = object>({
// eslint-disable-next-line react-hooks/rules-of-hooks
useDeprecated(
"The `redirect` prop on <Screen /> is deprecated and will be removed. Please use `router.redirect` instead",
redirect
Boolean(redirect)
);
}

Expand Down