Have you considered this way of working with "reactive"? In my opinion it's better than use .value but have all the best of "ref" kind of declaration
<template><divid="app"><inputv-model="val"/>{{$val}}</div></template><script>import{reactive,computed}from"vue";exportdefault{setup(){conststate=reactive({});state.val="abc";state.$val=computed(()=>`--${state.val}--`);state.arrayVal=[];// array is reactive and you can reassign itreturnstate;},};</script>
Yes. I actually proposed that to Evan before too. But after actually using the composition API, I was surprised to find ref much more natural to use. Having said that, using a state object is totally valid pattern tho!
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Have you considered this way of working with "reactive"? In my opinion it's better than use .value but have all the best of "ref" kind of declaration
Yes. I actually proposed that to Evan before too. But after actually using the composition API, I was surprised to find ref much more natural to use. Having said that, using a
stateobject is totally valid pattern tho!