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.

Error with `storeToRefs` in Vue 2

See original GitHub issue

Reproduction

https://github.com/Djaler/pinia-vue-2-store-to-refs

Steps to reproduce the behavior

  1. npm install
  2. npm run dev
  3. Open in browser

Expected behavior

Two numbers displayed beside a button.

Actual behavior

Value, created using storeToRefs is undefined

Additional information

If we debug storeToRefs function, we’ll see that store['counter'] is just a plain number, not a ref.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:3
  • Comments:10 (3 by maintainers)

github_iconTop GitHub Comments

4reactions
posvacommented, Nov 29, 2021

This is because of https://github.com/vuejs/composition-api/issues/844, use toRefs() as a workaround for the moment.

2reactions
posvacommented, Feb 21, 2022

For the moment, I think the best is to add a runtime dev-only warning if the user is using Vue 2 that says this feature is not supported, recommend them to use toRefs() instead and link to this issue. This should be a good first issue if anybody wants to pick it up!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Pinia - Watching storeToRefs in composable function does not ...
I think you can watch values inside composables. But, to watch a pinia state it has to be inside an arrow function:.
Read more >
Testing stores - Pinia
Initial State; Customizing behavior of actions; Specifying the createSpy function; Mocking getters; Pinia Plugins. E2E tests; Unit test components (Vue 2) ...
Read more >
State management with Pinia - Quasar Framework
It will create a folder in /src/stores named by “store_name” from the command above. It will contain all the boilerplate that you need....
Read more >
Mutate Application State Properties Directly with Pinia's ...
2. Mount and Test a Vue 3 Component in Cypress ... Mutate Application State Properties Directly with Pinia's storeToRefs(). 2m 26s.
Read more >
Quick Full Pinia Course. Vue VueX Pinia Store State Action…
But the problem is there is no connection between the two “message” properties. They are just two different properties who happen to have...
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