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

useStorageLocal in dev and build mode #120

Open
5 tasks done
thanhnguyen0904 opened this issue Mar 26, 2023 · 2 comments
Open
5 tasks done

useStorageLocal in dev and build mode #120

thanhnguyen0904 opened this issue Mar 26, 2023 · 2 comments

Comments

@thanhnguyen0904
Copy link

thanhnguyen0904 commented Mar 26, 2023

Describe the bug

Hello guys, im having a issue when create a login page. I tried to console.log(storageDemo) in setup hook, in dev mode it prints correct value, but in build mode it always prints default value. You can see my screenshot below.
Screenshot 2023-03-26 at 18 59 06

In dev mode:
Screenshot 2023-03-26 at 18 56 01

In build mode:
Screenshot 2023-03-26 at 18 54 33

Please help, thanks in advance!

Reproduction

https://github.com/antfu/vitesse-webext/blob/refactor/mv3/src/popup/Popup.vue

System Info

System:
    OS: macOS 13.2.1
    CPU: (8) arm64 Apple M1
    Memory: 526.91 MB / 16.00 GB
    Shell: 5.8.1 - /bin/zsh
  Binaries:
    Node: 18.12.1 - ~/.nvm/versions/node/v18.12.1/bin/node
    npm: 8.19.2 - ~/.nvm/versions/node/v18.12.1/bin/npm
  Browsers:
    Chrome: 111.0.5563.110
    Firefox: 106.0
    Safari: 16.3

Used Package Manager

pnpm

Validations

  • Follow our Code of Conduct
  • Read the Contributing Guide.
  • Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
  • Check that this is a concrete bug. For Q&A, please open a GitHub Discussion instead.
  • The provided reproduction is a minimal reproducible of the bug.
@thanhnguyen0904
Copy link
Author

im going a bit tricky by comunicate with background by sendMessage and it works, still expecting better solution though

@tmkx
Copy link
Collaborator

tmkx commented Mar 12, 2024

it doesn't seem to be a problem, it depends on the order of rendering and storage accessing.
storageDemo is a reactive value, if you want to get the latest value, use storage.local.get, if you want to subscribe to the latest value, use watch/watchEffect

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

2 participants