Skip to content

[Bug]: Using the browser back button console logs a warning #9998

@matijs

Description

@matijs

What version of React Router are you using?

6.8.0

Steps to Reproduce

Minimal test case at https://stackblitz.com/edit/react-ts-gphlmg?file=App.tsx

  1. Navigate to ‘foo’ or ‘bar‘ using the link on the page
  2. Use browser back button to navigate back to the ‘index’
  3. Use the browser forward button to navigate to ‘foo’ or ‘bar’ again

NB. Using only the links on the page works as expected without any warnings in the console.

Expected Behavior

There should (probably?) be no warnings in the console in this simple use case. Nothing is actively blocked and no navigation outside of the router happens (unless using the browser's back/forward button is considered navigation outside of the router).

Actual Behavior

The following warning is logged in the console:

You are trying to use a blocker on a POP navigation to a location that was not created by @remix-run/router. This will fail silently in production. This can happen if you are navigating outside the router via window.history.pushState/window.location.hash instead of using router navigation APIs. This can also happen if you are using createHashRouter and the user manually changes the URL.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions