expo / router

[ARCHIVE]: Expo Router has moved to expo/expo -- The File-based router for universal React Native apps
https://docs.expo.dev/routing/introduction/
1.36k stars 113 forks source link

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

Closed marklawlor closed 11 months ago

marklawlor commented 1 year ago

Motivation

Fix ENG-9886.

Execution

useDeprecated is a hook I added a while ago to easily log deprecated warnings once, and handle edge cases such as preventing multiple warnings during SSR & CI environment. I added code comments to explain its parameters.

The issue was the guard has a default value of true. So if you pass undefined, instead of using undefined it will switch to true. This is counter intuitive and a sign this hook needs to be refactored.

I like the guard having a truthy default, because you can simply write useDeprecated(<message>) with no guard. Maybe we need to split it into two functions?

useDeprecated(<message>, <key>)
useDeprecatedWithGuard(<message>, <guard>, <key>)
linear[bot] commented 1 year ago
ENG-9886 Using useSearchParams will warn with the wrong message

The following warning is thrown: ``` The `redirect` prop on is deprecated and will be removed. Please use `router.redirect` instead ```

nabilfreeman commented 11 months ago

Any updates here? This is the cause of the false positive warning

The `redirect` prop on <Screen /> is deprecated and will be removed. Please use `router.redirect` instead

that is bugging a lot of people on the latest Expo Router (2.0.8) and latest Expo SDK (49)