Subscribe on changes!

@vue/reactivity computed not working in svelte project

avatar
Nov 6th 2022

Vue version

"@vue/reactivity": "^3.2.41"

Link to minimal reproduction

no have

Steps to reproduce

I want test @vue/reactivity in svelte project

simple code is here

<script>
  import { ref, computed, effect } from "@vue/reactivity";

  let kao = ref(123)
  let foo = computed(() => kao.value * 2)

  function onClick(e) {
    kao.value += 1
  }

</script>

<main>
  <p>
    kao: {kao.value}
  </p>
  <p>
    foo: {foo.value}
  </p>
  <button on:click={onClick}>click me</button>
</main>

when click, foo's value can not recalculate.

What is expected?

foo's value (computed) can recalculate when kao update

What is actually happening?

foo's value not recalculate

System Info

System:
    OS: macOS 13.0
    CPU: (4) x64 Intel(R) Core(TM) i5-7267U CPU @ 3.10GHz
    Memory: 51.03 MB / 8.00 GB
    Shell: 5.8.1 - /bin/zsh
  Binaries:
    Node: 18.9.1 - /usr/local/bin/node
    npm: 8.19.1 - /usr/local/bin/npm
  Browsers:
    Chrome: 107.0.5304.87
    Firefox: 106.0.3
    Safari: 16.1

Any additional comments?

No response

avatar
Nov 6th 2022

Vue's reactivity will not trigger a svelte update/re-render. Without that, thr computed property will not be read again, so it wont be re-evaluated again.

I'll move this to discussions