Skip to content

Commit

Permalink
fix(ENG-9886): deprecated false positive (#859)
Browse files Browse the repository at this point in the history
  • Loading branch information
marklawlor authored Oct 6, 2023
1 parent 530821d commit 9f8a67b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
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

0 comments on commit 9f8a67b

Please sign in to comment.