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

[Bug]: useSearchParams does not update when using navigate / useNavigate #10809

Closed
dor6-deepcred opened this issue Aug 23, 2023 · 3 comments
Closed
Labels

Comments

@dor6-deepcred
Copy link

What version of React Router are you using?

6.15 / 6.14

Steps to Reproduce

create a button that adds a search param using useNavigate (lets say a=tralala)
use useSearchParams to get the search params, render searchParams.get("a");

Expected Behavior

after clicking the button "tralala" will be rendered

Actual Behavior

after clicking the button nothing will be rendered

@timdorr
Copy link
Member

timdorr commented Aug 23, 2023

Can you add a reproduction of this? There's not enough info here to know what's going on. Here are the starters:

Using <RouterProvider>
Using <BrowserRouter>

@dor6-deepcred
Copy link
Author

@timdorr
I tried to recreate and failed with the links
Its not related to navigate i switched the logic to use useSearchParams and it did not help
why could it happen where It get updated using the the same useSearchParams object but when changing the search params from somewhere else it does not (only when i open the browser)
we use BrowserRouter

@timdorr
Copy link
Member

timdorr commented Aug 27, 2023

This doesn't sound like a bug, just a misuse of the API. Unless you can create a reproduction somewhere (it doesn't have to be StackBlitz), there's not enough information to work with here. You should consult other help resources, like our Discord server.

@timdorr timdorr closed this as completed Aug 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants