Skip to content

Pinia stores imported from npm packages are not reactive or don't share the same context #2676

Discussion options

You must be logged in to vote

I reproduced your case, both with and without @vue/reactivity marked as external. If you add these console.logs, you will see the state does get updated, and the effect from @vue/reactivity does trigger on changes. But using watch from vue does not:

// counter.js
import { ref, effect } from '@vue/reactivity'
import { defineStore } from 'pinia'

export const useCounterStore = defineStore('counterStore', () => {
    const count = ref(0)

    function increment() {
        console.log(`pinia-package-test: increment to ${count.value + 1}`);
        count.value++
    }

    function decrement() {
        console.log(`pinia-package-test: decrement to ${count.value - 1}`);
        count.value--

Replies: 1 comment 4 replies

Comment options

You must be logged in to vote
4 replies
@waldemarennsaed
Comment options

@waldemarennsaed
Comment options

@kevinramharak
Comment options

Answer selected by waldemarennsaed
@waldemarennsaed
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #2675 on May 25, 2024 20:44.