paoloricciuti / sveltekit-search-params

The easiest way to read and WRITE from query parameters in sveltekit.
https://sveltekit-search-params.netlify.app
MIT License
547 stars 19 forks source link

Updating to SvelteKit 2 leads to warning #66

Open myieye opened 9 months ago

myieye commented 9 months ago

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 commented 9 months ago

Which version of this library you are using?

jycouet commented 9 months ago

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 commented 9 months ago

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 commented 9 months ago

I didn't look too much into it.

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

paoloricciuti commented 9 months ago

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 commented 9 months ago

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

paoloricciuti commented 9 months ago

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 commented 9 months ago

Last kit version release note:

I'll check that and let you know 👍

EDIT: it didn't change anything.