This repository was archived by the owner on Mar 17, 2025. It is now read-only.
Allow to ignore initialParams when using useSearchParams #382
mauricedoepke
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
When you call the app via a link, e.g.
myapp://items/1234
while you defined these routes:
The itemId property will be set as an initialParam in react navigation. This means even if you navigate to
/itemswhich might be a list of items,useSearchParamswill still return1234as itemId.When you navigate to a another item, the initial param will be propperly shadowed by the correct id, but once you navigate back to the list page
useSearchParamswill again return1234as itemId.This is problematic if some components of your app rely on
itemIdbeing undefined if no specific item is displayed.I think it would be nice to have some option like useSearchParams({ignoreInitialParams: true) to deal with this case.
Beta Was this translation helpful? Give feedback.
All reactions