Skip to content

After defining routes with patchRoutes, trying to navigate to URL containing #hash is throwing an errorΒ #13179

@Westman18

Description

@Westman18

I'm using React Router as a...

library

Reproduction

  1. Go to router-fragment-navigation-error on Stackblitz
  2. Wait for the app to start
  3. Manually add .../mock route to the URL
  4. Refresh the page and observe the navigation working as expected.
  5. Manually add any fragment (hash) to the working URL (.../mock#test).
  6. Refresh the page and observe the 404 Not Found react router error.

System Info

System:
    OS: Windows 10 10.0.19045
    CPU: (16) x64 11th Gen Intel(R) Core(TM) i7-11850H @ 2.50GHz
    Memory: 8.33 GB / 31.67 GB
  Binaries:
    Node: 20.18.2 - C:\Program Files\nodejs\node.EXE
    npm: 10.8.2 - C:\Program Files\nodejs\npm.CMD
  Browsers:
    Edge: Chromium (129.0.2792.52)
    Internet Explorer: 11.0.19041.4355

Used Package Manager

npm

Expected Behavior

Navigating to a route containing hash should not throw 'no route matches url' error.
(routes are already defined at this point with .patchRoutes())

Actual Behavior

After the routes are defined with .patchRoutes(), navigating to a route containing hash (#) is throwing us an error:
Image
The same navigation, but to route without hash is working correctly in this scenario.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions