Skip to content

After navigating in useEffect, it goes two pages backwards when pressing the back button #13955

Closed
@bb-in-hoodie

Description

@bb-in-hoodie

Reproduction

code: https://github.com/bb-in-hoodie/react-router-use-effect-issue

  1. let's say the first page is called Page1
  2. in Page1, navigate to Page2 in useEffect
  3. in Page2, press back button of the browser
[the initial tab page of a browser] → access the server → [first page] → useEffect + navigate → [second page] → press back button of the browser → ???

System Info

- tested on the latest chrome and safari in mac
- react router 7.5.3 and older

Used Package Manager

pnpm

Expected Behavior

  • goes back to the first page

Actual Behavior

  • goes back to the initial tab, skipping the first page
    • even though there still is a record of the first page observable on the browser history (by right clicking on the back button)
react-router-useeffect-issue-2025-07-08.mov

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