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]: Navigation don't work with createBrowserRouter sometimes #11393

Closed
NainikYork opened this issue Apr 2, 2024 · 2 comments
Closed

[Bug]: Navigation don't work with createBrowserRouter sometimes #11393

NainikYork opened this issue Apr 2, 2024 · 2 comments
Labels

Comments

@NainikYork
Copy link

NainikYork commented Apr 2, 2024

What version of React Router are you using?

6.22.1

Steps to Reproduce

const router = createBrowserRouter(
    createRoutesFromElements(
      <> </>
    )

When we defined our routes like this, then sometime the routes are not getting redirect using navigate properly sometimes.

Expected Behavior

image When using navigate it is not redirecting

Actual Behavior

It should redirect to that route

@NainikYork NainikYork added the bug label Apr 2, 2024
@timdorr
Copy link
Member

timdorr commented Apr 2, 2024

You're setting the browser location before using the React Router navigate(). This is superceding the library's navigation and will refresh the entire page, clearing out any saved state and reloading your application. You should use just the navigate() function alone.

@timdorr timdorr closed this as completed Apr 2, 2024
@NainikYork
Copy link
Author

I was using only navigate function only initially. When it has not worked I have put the window location method

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