Error with `storeToRefs` in Vue 2
See original GitHub issueReproduction
https://github.com/Djaler/pinia-vue-2-store-to-refs
Steps to reproduce the behavior
- npm install
- npm run dev
- 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:
- Created 2 years ago
- Reactions:3
- Comments:10 (3 by maintainers)
Top 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 >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
This is because of https://github.com/vuejs/composition-api/issues/844, use
toRefs()
as a workaround for the moment.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!