-
-
Notifications
You must be signed in to change notification settings - Fork 10.8k
Closed
Labels
Description
I'm using React Router as a...
library
Reproduction
https://stackblitz.com/edit/react-router-timing-om2qkn6g?file=src%2FApp.tsx
- Click "Enable slowdown."
- Experiment with clicking on the various numbered links.
- Note that, sometimes, the resulting link is
/n-1/binstead of/nor/n/b- in other words, the redirect takes effect from a previous browser location instead of the current browser location, and the user's manual navigation is lost.
System Info
System:
OS: macOS 15.1.1
CPU: (10) arm64 Apple M1 Pro
Memory: 151.58 MB / 16.00 GB
Shell: 5.9 - /bin/zsh
Binaries:
Node: 18.20.5 - ~/.nvm/versions/node/v18.20.5/bin/node
Yarn: 4.5.3 - /opt/homebrew/bin/yarn
npm: 10.8.2 - ~/.nvm/versions/node/v18.20.5/bin/npm
bun: 1.1.26 - /opt/homebrew/bin/bun
Browsers:
Chrome: 131.0.6778.140
Edge: 131.0.2903.99
Safari: 18.1.1
Safari Technology Preview: 18.2Used Package Manager
yarn
Expected Behavior
Using useEffect to trigger a navigation operation based off of the current location works as expected.
Actual Behavior
Because useLocation is updated asynchronously, by a React transition, it may lag behind the actual browser location.
brianmcd, titenis, rstarkov and eliasrmz01