question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Problems using useLocalStorage with pinia and typescript

See original GitHub issue

Describe 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: image

And this is the error that I am getting: image

I get a different error when a type the ref as follows: image

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

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:10 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
wheatjscommented, Apr 15, 2022

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.

1reaction
StefanGhibancommented, Apr 15, 2022

Can you provide a minimal reproduction demo? I don’t have this problem in my project

I will try to make a repo for this issue after the weekend. I will tag you when I have it. Thanks.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found