Skip to content

beforeLoad stuck with the params from first load #5785

@MagMar94

Description

@MagMar94

Which project does this relate to?

Router

Describe the bug

The params is correctly used in beforeLoad for the route the first time it is loaded. The second time the route is loaded, but with another parameter, the beforeLoad-function will use the parameter from the first load again.

Your Example Website or App

https://stackblitz.com/edit/github-hayqaewe?file=src%2Froutes%2Flist_%2F%24number.tsx

Steps to Reproduce the Bug or Issue

  1. Navigate to "List" in the minimal example
  2. Select one of the links that goes through the beforeLoad in src/routes/list_/$number.tsx (item 1, 2, 3 or the first 4).
  3. Click "List" in the menu again
  4. Select another one of the links that goes through the beforeLoad in src/routes/list_/$number.tsx (1-3). Notice that the number on the page does not match the one you clicked.

Expected behavior

As a user, I expected the beforeLoad to use the param from the route I clicked, but instead the param from a previous click was used.

Screenshots or Videos

BeforeLoadBug.mov

Platform

  • Router: [1.133.36]
  • OS: [macOS]
  • Browser: [Edge]
  • Browser Version: [142.0.3595.53]
  • Bundler: [vite]
  • Bundler Version: [7.0.0]

Additional context

Bug appeared when migrating from 1.132.27 to 1.133.36

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions