You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When the storage stores '100' (as a string), upon reloading the page, the retrieved value from storage becomes 100 (as a number).
In the context of Nuxt SSR, using useStorage along with ssrHandler stores data in cookies. However, when the stored data is a number, accessing it through "storage!.getItem(key)" automatically converts it to a number, whereas the required data type is a string.
Although StorageSerializers.string has been configured for conversion, inspecting the source code reveals that when the type is not a string, serializers.read is not executed, resulting in a type error in the end.
Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
Make sure this is a VueUse issue and not a framework-specific issue. For example, if it's a Vue SFC related bug, it should likely be reported to https://github.com/vuejs/core instead.
Check that this is a concrete bug. For Q&A open a GitHub Discussion.
Describe the bug
When the storage stores '100' (as a string), upon reloading the page, the retrieved value from storage becomes 100 (as a number).
In the context of Nuxt SSR, using useStorage along with ssrHandler stores data in cookies. However, when the stored data is a number, accessing it through "storage!.getItem(key)" automatically converts it to a number, whereas the required data type is a string.
Although StorageSerializers.string has been configured for conversion, inspecting the source code reveals that when the type is not a string, serializers.read is not executed, resulting in a type error in the end.
value is number already.
vueuse/packages/core/useStorage/index.ts
Lines 231 to 255 in 1558cd2
vueuse/packages/core/useStorage/index.ts
Line 249 in 1558cd2
getItem is number
vueuse/packages/nuxt/ssr-plugin.mjs
Lines 4 to 16 in 1558cd2
Reproduction
https://stackblitz.com/edit/github-rwbaw3?file=app.vue
System Info
Used Package Manager
npm
Validations
The text was updated successfully, but these errors were encountered: