SearchParams Sync Issue During First Effect Execution with window.history.replaceState() #72322
Labels
bug
Issue was opened via the bug report template.
Navigation
Related to Next.js linking (e.g., <Link>) and navigation.
Link to the code that reproduces this issue
https://github.com/yongholeeme/reproduction-bug-history-api-in-effect-nextjs/blob/main/Bug.jsx
To Reproduce
foo
's value has to be changedbar
according to1. When query
foois over 5, call window.history.replaceState() in effect
?foo=bar
, butconsole.log()
don't be executed in useEffect hassearchParams
dependency.router.refresh()
,?foo=100
query is back.Screen.Recording.2024-11-05.at.5.53.22.PM.mov
Current vs. Expected behavior
Wherever
window.history.replaceState()
is called, it's be synchronized with Router.Provide environment information
Operating System: Platform: darwin Arch: arm64 Version: Darwin Kernel Version 24.0.0: Tue Sep 24 23:37:13 PDT 2024; root:xnu-11215.1.12~1/RELEASE_ARM64_T8112 Available memory (MB): 24576 Available CPU cores: 8 Binaries: Node: 20.13.1 npm: 10.5.2 Yarn: N/A pnpm: 9.1.1 Relevant Packages: next: 15.0.2 // Latest available version is detected (15.0.2). eslint-config-next: N/A react: 19.0.0-rc-02c0e824-20241028 react-dom: 19.0.0-rc-02c0e824-20241028 typescript: N/A Next.js Config: output: N/A
Which area(s) are affected? (Select all that apply)
Navigation
Which stage(s) are affected? (Select all that apply)
next dev (local), next start (local), Vercel (Deployed)
Additional context
No response
The text was updated successfully, but these errors were encountered: