Problems using useLocalStorage with pinia and typescript
See original GitHub issueDescribe the bug
I am not able to get useLocalStorage in pinia with typescript to work. This is the code that I have inside an auth.ts file:
And this is the error that I am getting:
I get a different error when a type the ref as follows:
Reproduction
System Info
System:
OS: macOS 12.3.1
CPU: (8) arm64 Apple M1
Memory: 103.19 MB / 16.00 GB
Shell: 5.8 - /bin/zsh
Binaries:
Node: 16.13.0 - ~/.nvm/versions/node/v16.13.0/bin/node
Yarn: 1.22.17 - /opt/homebrew/bin/yarn
npm: 8.1.0 - ~/.nvm/versions/node/v16.13.0/bin/npm
Browsers:
Chrome: 100.0.4896.88
Firefox: 97.0.1
Safari: 15.4
npmPackages:
@vueuse/core: ^8.2.5 => 8.2.5
@vueuse/integrations: ^8.2.5 => 8.2.5
vue: ^3.2.31 => 3.2.31
Used Package Manager
npm
Validations
- Follow our Code of Conduct
- Read the Contributing Guidelines.
- Read the docs.
- 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.
- The provided reproduction is a minimal reproducible example of the bug.
Issue Analytics
- State:
- Created a year ago
- Comments:10 (2 by maintainers)
Top Results From Across the Web
3 Ways to Persist Pinia State - YouTube
A common use case for all data stores is the need to persist data. In this video, we'll see a few different approaches...
Read more >How to create a persistant state for Pinia + Quasar?
To initialize the user state with Local Storage data, use Quasar's LocalStorage.getItem() , and default to an empty object:
Read more >How do you persist Pinia state across reloads : r/vuejs - Reddit
I've been trying to learn Pinia using the options api and JS. ... So when using useLocalStorage it'll implicitly know when to set/get...
Read more >Simple Local Storage implementation using Vue 3, Vueuse ...
Sometimes you just neeeeed a local storage utility without headaches. Currently Pinia is still in the progress of constructing their plugin ...
Read more >Advantages of Pinia vs Vuex - Vue Mastery
But do you know why you should be using Pinia over Vuex and how to use ... However, when using Pinia with TypeScript,...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I also am unable to reproduce this, but just as a note you don’t need to wrap
useLocalStorage
in a ref as it is already a ref.I will try to make a repo for this issue after the weekend. I will tag you when I have it. Thanks.