Can somebody explain to me why reactivity breaks for number
in this example:
https://codesandbox.io/s/vue-3-reactivity-issue-4rto59?file=/public/index.html
I have 2 composables (useNumber.js and useRandomNumber.js) which I both spread in the return of the setup()
function in my main.js
file.
The useNumber
composable functionality (adding 1 to number) is triggered from within setup()
.
The useRandomNumber
functionality (generating a random number) is triggered from within itself via setInterval
.
Both number.value
and randomNumber.value
are used inside index.html
but only randomNumber
remains reactive.
While both remain reactive inside setup()
.
Why does the spreading not break both variables but only on number
?
How my example works:
The randomNumber
is changing onscreen. So this is reactive.
The number
can be altered by clicking the ADD button. As you will see, the value changes in the console (as this is from within setup()
) but not on screen from the return
.
I'd expect that reactivity for both would work OR break due to the spreading.