Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updating to SvelteKit 2 leads to warning #66

Open
myieye opened this issue Feb 1, 2024 · 8 comments
Open

Updating to SvelteKit 2 leads to warning #66

myieye opened this issue Feb 1, 2024 · 8 comments

Comments

@myieye
Copy link

myieye commented Feb 1, 2024

Describe the bug

We just updated from "@sveltejs/kit": "^1.24.1" to "@sveltejs/kit": "^2.5.0" and started getting the warning:

Avoid using history.pushState(...) and history.replaceState(...) as these will conflict with SvelteKit's router. Use the pushState and replaceState imports from $app/navigation instead.

Reproduction

This just happens every time we write to the query-params.

Logs

No response

@paoloricciuti
Copy link
Owner

Which version of this library you are using?

@jycouet
Copy link

jycouet commented Feb 19, 2024

using "sveltekit-search-params": "2.1.0", I have also the same thing after removing all replaceState in my own code.
I guess that it's coming from sveltekit-search-params

@paoloricciuti
Copy link
Owner

using "sveltekit-search-params": "2.1.0", I have also the same thing after removing all replaceState in my own code. I guess that it's coming from sveltekit-search-params

If you try to search the codebase there's no instance of replaceState except for the option that i pass to goto but i explored sveltekit code and it's actually using history.replaceState under the hood.

Maybe i should use replaceState instead of passing the option to goto but that would introduce conflicts with previous versions of sveltekit

@jycouet
Copy link

jycouet commented Feb 19, 2024

I didn't look too much into it.

Would be great if sveltekit warning tells us from where it is 😁

@paoloricciuti
Copy link
Owner

I just tryed to use replaceState if available...unfortunately it doesn't work because it doesn't propagate changes to the $page store which the library rely on.

@jycouet
Copy link

jycouet commented Feb 20, 2024

Thx for the test.
That mean that you also have the warn in the console?

@paoloricciuti
Copy link
Owner

Actually I didn't saw a warn in the console...but regardless there's nothing that I can do (except fixing upstream) on my side. :(

@jycouet
Copy link

jycouet commented Feb 28, 2024

Last kit version release note:

  • fix: prevent false positive history.pushState and history.replaceState warnings

I'll check that and let you know 👍

EDIT: it didn't change anything.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants