- Notifications
You must be signed in to change notification settings - Fork544
[⚠️ Dropped] Reactivity Transform#369
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
-
This Proposal has been DroppedSeereasoning here. SummaryIntroduce a set of compiler transforms to improve ergonomics when using Vue's reactivity APIs, specifically to be able to use refs without Basic example// declaring a reactive variable backed by an underlying refletcount=$ref(1)// log count, and automatically log again whenever it changes.// no need for .value anymore!watchEffect(()=>console.log(count))functioninc(){// assignments are reactivecount++} Compiled Outputimport{watchEffect,ref}from'vue'constcount=ref(1)watchEffect(()=>console.log(count.value))functioninc(){count.value++} MotivationEver since the introduction of the Composition API, one of the primary unresolved questions is the use of refs vs. reactive objects. It can be cumbersome to use This proposal aims to improve the ergonomics of refs with a set of compile-time macros. Detailed designOverview
Reactive VariablesTo understand the issue we are trying solve, let's start with an example. Here's a normal ref, created by the original import{ref,watchEffect}from'vue'constcount=ref(0)watchEffect(()=>{// access value (track)console.log(count.value)})// mutate value (trigger)count.value=1 The above code works without any compilation, but is constrained by how JavaScript works: we need to use the Now let's look at a version usingreactive variables: import{watchEffect}from'vue'letcount=$ref(0)watchEffect(()=>{// access value (track)// compiles to `console.log(count.value)`console.log(count)})// mutate value (trigger)// compiles to `count.value = 1`count=1 This version behaves exactly the same as the original version, but notice that we no longer need to use The Every reactivity API that returns refs will have a
Optional ImportBecause import{$ref}from'vue/macros'letcount=$ref(0) Bind existing ref as reactive variables with |
BetaWas this translation helpful?Give feedback.
All reactions
👍 231👎 42😄 8🎉 44😕 16❤️ 62🚀 49👀 18
Replies: 160 comments 489 replies
-
I really like the switch to a regular JS syntax in this proposal, this reads so much better now, good job! I also like the ergonomics of But I would also like to question the |
BetaWas this translation helpful?Give feedback.
All reactions
👍 6
-
I don't think there is a way around this - you needsome form of compiler hint when you intend to treat destructured variables as refs, and it also needs to account for proper type inference (which the wrapper function does). |
BetaWas this translation helpful?Give feedback.
All reactions
👍 8🎉 7❤️ 4
-
Can we unify standards, such as $defineProps |
BetaWas this translation helpful?Give feedback.
All reactions
-
In order for this to work, |
BetaWas this translation helpful?Give feedback.
All reactions
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
-
Any build setup that can compile Vue SFCs already should include |
BetaWas this translation helpful?Give feedback.
All reactions
This comment has been hidden.
This comment has been hidden.
This comment has been hidden.
This comment has been hidden.
This comment has been hidden.
This comment has been hidden.
This comment has been hidden.
This comment has been hidden.
This comment has been hidden.
This comment has been hidden.
-
|
BetaWas this translation helpful?Give feedback.
All reactions
-
|
BetaWas this translation helpful?Give feedback.
All reactions
😕 1
-
What about writable computed? |
BetaWas this translation helpful?Give feedback.
All reactions
-
How to use |
BetaWas this translation helpful?Give feedback.
All reactions
-
But if i used it like this? letval=$ref(0)constcomputedVal=$computed({get(){returnval+1},set(payload){val=payload}}) Obviously, if i try to change the |
BetaWas this translation helpful?Give feedback.
All reactions
This comment has been hidden.
This comment has been hidden.
-
这写法简直太棒了,我喜欢这种写法, 比ref: count = 0 ,更香 |
BetaWas this translation helpful?Give feedback.
All reactions
👍 6❤️ 1
-
ref:这种写法IDE识别会报错,毕竟不是声明变量的正确方式,换了这种之后IDE不会报红色的波浪线了 |
BetaWas this translation helpful?Give feedback.
All reactions
👍 1
-
这种TS怎么写啊 |
BetaWas this translation helpful?Give feedback.
All reactions
-
新版本已经删掉了这个特性,不建议使用了,如果确定需要使用的话,可以通过vue-macros这个包来使用,ts可以在全局.d.ts文件内引用类型定义 /// |
BetaWas this translation helpful?Give feedback.
All reactions
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
-
我发现我犯了一个错误: I found that I made a mistake: 我们可以沿用JS/TS的语法和语义,定义一种简单的编译模式:只需要对变量声明语句做出一些特殊处理: We can follow the syntax and semantics of JS / TS and define a simple compilation mode: we only need to make some special processing for variable declaration statements: <script lang="ts">"use ref"let a:number=1const b=2let c=a+bconst d=a+b+clet e=$computed(()=>a+b)const f=$computed(()=>a+b)</script> Compiled output<script>consta=ref(1)constb=unref(2)constc=ref(a.value+ b)constd=unref(a.value+ b+c.value)conste=ref(computed(()=>a.value+ b))constf=unref(computed(()=>a.value+ b))</script> 也可以应用于SFC外部的JS/TS源文件: It can be supported outside of SFCs. functionuseMouse(){"use ref"letx=0lety=0functionupdate(e){x=e.pageXy=e.pageY}onMounted(()=>window.addEventListener('mousemove',update))onUnmounted(()=>window.removeEventListener('mousemove',update))return{x:$ref(x),y:$ref(y),}} Compiled outputfunctionuseMouse(){constx=ref(0)consty=ref(0)functionupdate(e){x.value=e.pageXy.value=e.pageY}onMounted(()=>window.addEventListener('mousemove',update))onUnmounted(()=>window.removeEventListener('mousemove',update))return{x:x,y:y,}} 支持解构语法: Destruction syntax supported: "use ref"let{ x, y}=useMouse()const[count,setCount]=useState(0) Compiled outputconst__result__1=useMouse()constx=ref(__result__1.x)consty=ref(__result__1.y)const__result__2=useState(0)cosnt__iterator__1=__result__2[Symbol.iterator]()constcount=unref(__iterator__1.next().value)constsetCount=unref(__iterator__1.next().value) |
BetaWas this translation helpful?Give feedback.
All reactions
❤️ 5
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
-
How about variable name syntax sugar? - let count = $ref(0)+ let $count = 0- const plusOne = $computed(() => count + 1)+ const $plusOne = count + 1 |
BetaWas this translation helpful?Give feedback.
All reactions
👍 7👎 17😕 26
-
Then it would be a mess because people would be using different syntaxes and even mixing them. It also creates confusion for learning. It's better to stick to one design that can solve all cases. |
BetaWas this translation helpful?Give feedback.
All reactions
👍 38😕 2
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
-
Then how do you know that |
BetaWas this translation helpful?Give feedback.
All reactions
👍 4
-
@zhangenming we should know that at compile time as |
BetaWas this translation helpful?Give feedback.
All reactions
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
-
Someone else also proposed variable name syntax sugar. Maybe it is worth to be re-evaluated. In order to avoid confusion, we can rename |
BetaWas this translation helpful?Give feedback.
All reactions
-
But what if you're just trying to construct a letx=ref(y.value+1); |
BetaWas this translation helpful?Give feedback.
All reactions
-
To avoid "too much magic", could this be opt in instead of the default behaviour? Something like |
BetaWas this translation helpful?Give feedback.
All reactions
👍 10👎 8
-
Isn't it opt-in simply because if you don't want those macros you simply don't use them? |
BetaWas this translation helpful?Give feedback.
All reactions
👍 56
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
-
I agree that at best should be an opt-in feature, but via compiler options, not granular access on a function/script basis. |
BetaWas this translation helpful?Give feedback.
All reactions
-
Doesn't really work if you import components from other packages that are not already transpiled and still vue files. You need to keep it on the component level somehow |
BetaWas this translation helpful?Give feedback.
All reactions
👍 1
-
Good point, thanks! |
BetaWas this translation helpful?Give feedback.
All reactions
-
|
BetaWas this translation helpful?Give feedback.
All reactions
👎 39😄 3
-
不怎么样 |
BetaWas this translation helpful?Give feedback.
All reactions
👍 2👎 14😕 3
-
不怎么样 |
BetaWas this translation helpful?Give feedback.
All reactions
-
咦 我啥时候评论的这个 看不懂我想表达啥了 |
BetaWas this translation helpful?Give feedback.
All reactions
-
哈哈哈,应该是想用ref.auto代替$ref吧 |
BetaWas this translation helpful?Give feedback.
All reactions
This comment was marked as off-topic.
This comment was marked as off-topic.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
-
These are just sugars, and the compiled runtime API is still consistent with the original API. I think a runtime exception should be thrown when the sugars are called in non-sugar mode. import{$ref,shallow,custom,compute,unref,trigger}from'vue' |
BetaWas this translation helpful?Give feedback.
All reactions
👍 3
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
-
I have actually thought of the same idea before, but the problem is that the variable declaration code will look indistinguishable from code that isnot using the sugar - theonly hint is the import site. I think the sugar needs to be moreexplicit at the variable declaration sites rather than implicit. |
BetaWas this translation helpful?Give feedback.
All reactions
👍 10
-
In addition, I understand that you have been experimenting in this space, but please only use this thread for providing feedback for what is being proposed and avoid pitching your own proposal (you can use a separate thread for that and link to it here). |
BetaWas this translation helpful?Give feedback.
All reactions
-
These ideas are based on my assumption: in the scenario where ref sugar needs to be used, there are very few cases where non ref variables need to be declared (if any, |
BetaWas this translation helpful?Give feedback.
All reactions
-
Sorry, I had some ideas based on the current proposal at the beginning, so I want to share them here as soon as possible. I'll try to open a new thread later. |
BetaWas this translation helpful?Give feedback.
All reactions
-
Has anyone already proposed this? My half-baked thought is it would be better if $x just meant x.value and let $x = 0 was short for const x = ref(0). People are used to using $ from jQuery days to signify values that are special to a framework. If you need a dollar variable for legacy reasons, there can be a magic comment or label for raw mode, but it’s unusual to use dollar for normal template variables, so I don’t think it will be used often. |
BetaWas this translation helpful?Give feedback.
All reactions
-
It could work for computed too. let$n=0function$double(){return$n*2}// $double is now computed(double).value |
BetaWas this translation helpful?Give feedback.
All reactions
❤️ 2
-
See my comment#369 (comment) |
BetaWas this translation helpful?Give feedback.
All reactions
-
There's a lot to flesh out in such a proposal:
I think this is exactly what created much of the pushback on the initial proposal: the abuse of existing JS syntax in twisted ways. |
BetaWas this translation helpful?Give feedback.
All reactions
-
You refer to the variable name without the dollar sign. x is the ref; $x is the value. You could do setters with let$double={get:…set:…} For shallow refs and read only, I dunno, you could use labels I guess, like the old proposal/Svelte. |
BetaWas this translation helpful?Give feedback.
All reactions
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
-
Then it has all the problems with the previous proposal: TypeScript doesn't know the implicit relationship between |
BetaWas this translation helpful?Give feedback.
All reactions
👍 8
-
❤️ very happy to see this new proposal! When writing components, here we used a lot of reactive objects for state, that were simply returned from This proposal will greatly improve writing script setup by making refs work like any normal variables! 👍 About usage outside SFC componentsA few thoughts:
|
BetaWas this translation helpful?Give feedback.
All reactions
👍 6❤️ 1
-
Opting-in to Ref Sugar by convention via file suffix IMO, with how React community blatantly claims that JSX is "just Javascript", I honestly don't feel that introducing Ref Sugar to Vue ecosystem is any worse offender to "standard Javacript": we just need to look at our own DSL with the same mentality. Usage of Ref Sugar outside SFCs shouldn't be frown upon. |
BetaWas this translation helpful?Give feedback.
All reactions
-
Back in the day, when SFC was a novel concept and its tooling support was subpar, some Vue users used Webpack, Rollup, etc. loaders to build a virtual I like the extension idea, but it could clash with aforementioned usage. I particularly see no problem, as it never took off and solving the clash is just a question of remapping file names to some other convention. |
BetaWas this translation helpful?Give feedback.
All reactions
-
Interesting! I did not know that. In fact when it comes to loaders, the extension you process (or not) could be chosen in your build configuration. |
BetaWas this translation helpful?Give feedback.
All reactions
👍 3
-
It would be better if code: <scriptsetup> const foo = $({a:1})</script> compiled out: <scriptsetup> import{reactive} from 'vue' const foo = reactive({a:1})</script> |
BetaWas this translation helpful?Give feedback.
All reactions
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
-
The primary goal of the sugar is to remove the need for |
BetaWas this translation helpful?Give feedback.
All reactions
👍 20
-
make sense. 👍 |
BetaWas this translation helpful?Give feedback.
All reactions
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
-
Have you considered using jQuery? |
BetaWas this translation helpful?Give feedback.
All reactions
👎 8😄 6😕 2
-
I spent a few more hours playing around and getting a better feeling for the proposal. From a design perspective, there isn't much that I could complain about besides What I likedThe Reactive Variable let$count=$ref(0)// I mutate state!$count++ The problemAs soon as I started creating multiple modules and composable, the limitations of thefunction boundaries makes the initial syntax gains immediately decay. // Let's pretend each of these functions comes from a different moduleexportfunctionexpectsRef(r:Ref<any>):void{// ..}exportfunctionexpectsValue(v:any):void{// ..}exportfunctionuseFooBar(){returnreactive({a:'',b:'',})}exportfunctionuseBarBaz(){constc=ref('')constd=ref('')return$$({ c, d,})} As a developer navigating these files on my first onboarding on a codebase, if I don't have previous experience with Vue, I am immediately overwhelmed by the number of possibilities I have to pick from, to declare a reactive state. <script setup>constform=reactive({ email:'', password:''})const$count=$ref(0)const {a,b }=$(useFooBar())const {c,d }=$(useBarBaz())construn= ()=> {expectsRef($$($count))expectsValue($count)}</script> The above is indeed a very stretched example, but it's valid and supported syntax with correct usage of all those helpers and macros. If I were to work on such a codebase, I have to switch my mental model as if I were the compiler, wrapping/unwrapping refs line by line to invoke the correct macros and understand all the transformations that are happening. Now let's repeat this mental overhead for every file that I worked with, and I have immediately lost all the advantages of not having to use ConclusionsGiven the current constraints of JS language and to provide backward compatibility, I struggle to see how the current design could be further improved. However, if we do a cost/benefits analysis of this feature (removing the verbosity of The main issue of this proposal is the introduction ofyet another way of doing things in Vue and a further step into the fragmentation of the reactivity system and adopted conventions. If we add to the mix the struggle the framework has gone through in the migration from Options API to Composition API, we have a deadly combination of multiple variations to achieve the same thing. As I onboard a less experienced Software Engineer, or with no previous experience in Vue, I have to go through the following steps to successfully onboard them:
The current proposal introduces additional complexity with a discrepancy between compile-time/run-time, which leaves the developer the responsibility of picking the correct solution. The ultimate goal of a framework should be to abstract away from the developer that choice, and gracefully lead them towards theright way. SuggestionI understand that after the Vue 2 -> Vue 3 migration, considering yet another breaking change could be detrimental to the community and businesses using Vue, but I can't help but think that the I like Vue due to its simplicity and elegance, and I would like the framework to continue building on those aspects. Perhaps, what Vue needs, is to go back to the drawing board and consider a Vue 4 where both In the meanwhile, simply accessing |
BetaWas this translation helpful?Give feedback.
All reactions
👍 19❤️ 4
-
It's funny because I subscribed to this thread for the same reason as everyone else - to find a better way. But after all this time, I've come to think that .value really is the lesser of all evils - and I can't help but think that that is why it was done this way in the first place. |
BetaWas this translation helpful?Give feedback.
All reactions
👍 7
-
I think an emerging pattern for authors of Vue composables is writing functions that can receive both Vue refs and plain values (and, sometimes, even a getter functions) as argument. VueUse, perhaps the largest publisher of composables in the Vue community,do that everywhere; it's also been mentioned on talks by Vue team members likeAnthony Fu andThorsten Lünborg. Although it makes the life harder for authors of composables, it makes the life much easier for consumers of composables. |
BetaWas this translation helpful?Give feedback.
All reactions
❤️ 1
-
It should be pointed out that these are not equivalent alternatives! If the composable only wants to read a value without taking dependencies (i.e. outside computeds/watches/effects) and doesn't want to write back into the parameter, then I think it shouldonly accept plain values, as normal JS functions do. Assuming it wants reactivity, it should accept So if you were gonna pass |
BetaWas this translation helpful?Give feedback.
All reactions
-
I really like the SolidJS approach to the // current approachconstcount=ref(0)count.value++constdoubleCount=computed(()=>count.value*2)// getter and setterconst[count,setCount]=createRef(0);setCount(c=>c()+1);constdoubleCount=computed(()=>c()*2); |
BetaWas this translation helpful?Give feedback.
All reactions
-
Apart from plain JS functions prefixed with Another problem I didn't mention in my original comment: usually passing a ref is more useful than not, so it doesn't match the most intuitive usage, without |
BetaWas this translation helpful?Give feedback.
All reactions
-
How about instead of the |
BetaWas this translation helpful?Give feedback.
All reactions
-
I think it could cause TS issues, like |
BetaWas this translation helpful?Give feedback.
All reactions
-
Can we unify standards, such as $defineProps |
BetaWas this translation helpful?Give feedback.
All reactions
-
Just heard@yyx990803 announcement at Vue.js Nation 2023. Reactivity Transform will be dropped (but will be made available via a separate package to support compatibility for those who want to still use it). It's great to see that the Core Team listened carefully to the feedback from this RFC 🥳 . I believe it's the right call. The risk of further fragmentation with the release of this feature was simply too high. |
BetaWas this translation helpful?Give feedback.
All reactions
👍 33👎 3🎉 1😕 3❤️ 5
-
link to an article/video? |
BetaWas this translation helpful?Give feedback.
All reactions
-
BetaWas this translation helpful?Give feedback.
All reactions
👍 11🎉 3
-
Video link:https://youtu.be/OrT0tHGXyqE?t=844 |
BetaWas this translation helpful?Give feedback.
All reactions
👍 6
-
https://vuejsnation.com/You can join the conference and look for Evan's speech...Em qua., 25 de jan. de 2023 às 16:08, Veesh Goldman <***@***.***> escreveu: … link to an article/video? — Reply to this email directly, view it on GitHub <#369 (reply in thread)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AB5B65MRKDPJCZZON4OFLO3WUF24LANCNFSM5BR7T3KA> . You are receiving this because you commented.Message ID: ***@***.***> |
BetaWas this translation helpful?Give feedback.
All reactions
-
Hey, I'm just one of those people who quietly started using this feature ever since it was introduced and I was hoping eventually it'd land in mainline Vue, but to my disappointment it seems like the opposite is happening. I probably won't be the single person saying this, but I found this feature made my Vue DX tenfold better than what it was, and not needing to remember to put I'm not sure about the difficulties behind maintaining it, but writing code with Reactivity Transform to me felt natural and just resembled normal JS. I shipped many projects with it and all of them worked flawlessly, never encountered a single issue that was directly caused by Reactivity Transform. So my opinion here is that removing it from Vue and dropping support wouldn't be too great. Especially since if you look at the npm downloads for the Reactivity Transform package it's been only going up ever since the release of this feature, reaching the 2 million threshold. But that's just my 5 cents. |
BetaWas this translation helpful?Give feedback.
All reactions
👍 3👎 4❤️ 8
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
-
Large projects don't mean complex projects. I can make you a 20k lines "hello world".
Sorry, but shipping experimental stuff in production is not a very responsible thing to do. The fault is yours. |
BetaWas this translation helpful?Give feedback.
All reactions
-
I feel like your manner of speech is kind of accusatory and rude, it's not a good look. I'm just trying to take advantage of the good things Vue provides. I think the projects were complex enough, considering we are a team of 20 devs who were working over 6 months on it, having a bunch of external libraries, state management, complex transaction logic, and a whole bunch of other stuff. But this comment really isn't about me proving my point, if you choose to not believe it then that's on you, I was just trying to make my voice heard on this topic, and that's about the extent of it. I've worked with Vue for about 3 years now and I thought you people wanted to hear opinions that people have on your RFC-s. |
BetaWas this translation helpful?Give feedback.
All reactions
-
You can tryVue Macros |
BetaWas this translation helpful?Give feedback.
All reactions
-
Thanks, will probably keep using this if this really gets removed from Core, I guess at least there's a solution. |
BetaWas this translation helpful?Give feedback.
All reactions
-
There have been a total of four explicitly experimental features ever since the beginning of Vue:
Out of the four, two already became stable, and this is the very first time we are dropping an experimental feature. The point of the experimental label is exactly what it means: these are features that we need to ship and test in actual apps in order to further evaluate them. If it works, we keep them; if it doesn't, we drop them. In this specific case, it will be moved to a separate package like VueMacros, which is also maintained by a core team member. You make it sound like you've experienced experimental features dropped before (which we factually know never happened) and the 99% exaggeration is just unnecessary FUD. |
BetaWas this translation helpful?Give feedback.
All reactions
👍 21
Uh oh!
There was an error while loading.Please reload this page.
-
BetaWas this translation helpful?Give feedback.
All reactions
👎 10
-
It is an experimental feature. I do not see why you consider migrating away from Vue a better solution instead of using the stable API and adapting your workflow to it. |
BetaWas this translation helpful?Give feedback.
All reactions
👍 4
-
No need for being harsh. OP has a problem and is looking for a solution, not blame. Anyway, this RFC may be likely supported inside theVue Macros project. |
BetaWas this translation helpful?Give feedback.
All reactions
👍 2
-
Yeah there will 100% be a package that still gives you what was proposed here so its fine. |
BetaWas this translation helpful?Give feedback.
All reactions
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
-
At this point, I start questioning Vue's perspective around Javascript labels to create reactivity like Svelte. ($:) I remember that the main reason for not using it is the compatibility and lack of support with Typescript and other tools around the ecosystem. But Vue's DX currently is heavily balanced around not native tools like VSCode with Volar. Or Vue Macros (currently in the early stage but with a promising perspective).@antfu 's repos shaped the standard for the next years, and with tools likeInspect orNuxt Dev Tools it is clear that intermediate states are more relevant and easier to debug every day. It seems to me that DX is leaning toward UI-based inspectors and IDE Integrations. Volar seems to be leading this adventure. Seeing this thread, it's clear that a lot of jiggling needs to be made to provide a one-fits-all solution. I believe an approach closer to compiling time will satisfy a lot of people that use Vue to create user-facing apps. Because:
It doesn't have to be JS labels, but it seems that is the most native and friendly solution out there. Typescript macros are a good option too. |
BetaWas this translation helpful?Give feedback.
All reactions
👀 1
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
-
"Closer to compiling time"? You might be misled by the JS-compatible syntax: The main reason cited by the team for dropping this, AFAIK, is that it creates confusion at boundaries where state needs to be passed as a ref, or converted from a ref. It seems to me you're debating the syntax: maybe labels |
BetaWas this translation helpful?Give feedback.
All reactions
👍 6
-
Yep, you are right, I misunderstood the problem. |
BetaWas this translation helpful?Give feedback.
All reactions
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
-
As many of you are already aware, we are officially dropping this RFC with consensus from the team. The RationaleThe original goal of Reactivity Transform was to improve the developer experience by providing more succinct syntax when working with reactive state. We shipped it as experimental to gather feedback from real world usage. Despite the proposed benefits, we discovered the following issues:
And most importantly, the potential risk of fragmentation. Despite this being clearly opt-in, some users have expressed strong objections against the proposal, the reason being that they fear that they would have to work with different codebases where some opted to use it while some not. This is a valid concern because Reactivity Transform entails a different mental model that distorts JavaScript semantics (variable assignments being able to trigger reactive effects). All things considered, we believe landing it as a stable feature would result in more issues than benefits, and thus not a good trade-off. Migration Plans
|
BetaWas this translation helpful?Give feedback.
All reactions
👍 223👎 17🎉 5😕 19❤️ 1
-
Although I enjoyed the convenience of this feature, I did find this potential fragmentation problem in actual use. Removing this feature in a future release may be reluctant, but engineers should be serious. 🙂 |
BetaWas this translation helpful?Give feedback.
All reactions
👍 8
-
Are you removing all features or just the part with the |
BetaWas this translation helpful?Give feedback.
All reactions
👍 6
-
I love this feature but I also understand why it needed to be removed from the official package. <script setup lang="ts">interfaceProps { type?:'button'|'submit'|'reset';}const {type : propType='submit' }=defineProps<Props>();</script><template> <button:type="propType"> <slot /> </button></template> this snippet was valid when using Reactivity Transform before migrating but since using Vue Macros, I had to directly use type as the variable name in the template. |
BetaWas this translation helpful?Give feedback.
All reactions
👍 1
-
For everyone wondering what happens with the Reactive Props Destructure, Evan specifically mentions it in the Vue Nation Video here, that it will be seperated into its own Feature! |
BetaWas this translation helpful?Give feedback.
All reactions
❤️ 1
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
-
Any news? Edit: found it#502 |
BetaWas this translation helpful?Give feedback.
All reactions
👍 1
-
Hi all, I just stumbled across this and was surprised/disappointed to find that this proposal is being dropped. I've been using it for a moderately sized ecommerce site with no issues. I understand the rationale behind removing it, but in practice I found it to really be quite an improvement. So really my question is: "What now?" I think the missing piece of this discussion is clarifying where we are at with the original motivation. Personally, I like to do things the "recommended" way, so I'd actually rather remove usages of the reactivity transform proposal from my project (which hasn't grown to the point where such a change is unfeasible—part of the reason I was comfortable with using an experimental feature to begin with) rather than starting to depend on an external package which exists solely to provide a deprecated feature. So I'm curious about what the recommendation is now, particularly in the context of the original motivation:
I agree completely with this. Are we now concluding that there is no good solution to this problem? Is the recommendation for those who hate |
BetaWas this translation helpful?Give feedback.
All reactions
👍 8
-
Just like any other responsive library |
BetaWas this translation helpful?Give feedback.
All reactions
👍 17👎 2
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
-
what's meaning |
BetaWas this translation helpful?Give feedback.
All reactions
-
It should be pretty easy to create a package that reverse all the reactivity transform code? Having this as a migration away from it would be really nice. I agree with Aaron here, I also like doing things the recommanded way. |
BetaWas this translation helpful?Give feedback.
All reactions
-
你可以在macro里继续使用它 |
BetaWas this translation helpful?Give feedback.
All reactions
-
I like what@mcrapts said.
|
BetaWas this translation helpful?Give feedback.
All reactions
👍 4
-
Seems like the same complexity arguments apply to the in-template automatic transform. Will that also be going away? |
BetaWas this translation helpful?Give feedback.
All reactions
👍 2
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
-
It really doesn't make sense to have the Also, |
BetaWas this translation helpful?Give feedback.
All reactions
-
It makes sense for a new user who wasn't there at the beginning. So hard to explain "You have to access the value with .value, cuz that's how refs work! Wait why are you adding .value in the template, that's not what you're supposed to do! Refs are auto-unwrapped there, cuz it makes no sense to not use the value. Why Vue doesn't auto unwrap in the script tag as well? Well, we had this deprecated feature called Reactivity transform but..." |
BetaWas this translation helpful?Give feedback.
All reactions
👍 10
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
-
It is not hard at all given that there is exhaustive documentation material onReactivity Fundamentals where this concept is explained clearly and simply. You should expect any new user toat least read the documentation of the tool they intend to use. |
BetaWas this translation helpful?Give feedback.
All reactions
👍 3👎 1
-
Why are you angry? I've read through the documentation multiple times and am a seasoned Vue user 😆 But I won't pretend that this isn't one of the beginner issues of Vue 3 that didn't exist in Vue 2, not saying that Vue 2 wasn't without its fair amount of caveats. You can't expect beginner devs to know everything or learn everything at the same pace. I love reading docs, but others reflexively turn to tutorials first or video lessons and avoid docs like cats avoid water. |
BetaWas this translation helpful?Give feedback.
All reactions
👍 3👎 3
-
From your sentence, figure out a new API which is not |
BetaWas this translation helpful?Give feedback.
All reactions
-
@yyx990803 what about reactive props destructure:https://vuejs.org/guide/extras/reactivity-transform.html#reactive-props-destructure ? Would it remain in the core? |
BetaWas this translation helpful?Give feedback.
All reactions
-
He said during the conf that this specific part will be kept in core. |
BetaWas this translation helpful?Give feedback.
All reactions
-
Really? I didn't watch the vue conf. but I'm searching for it lately, I want to use vue({script:{propsDestructure:true,},}), |
BetaWas this translation helpful?Give feedback.
All reactions
👍 4
Uh oh!
There was an error while loading.Please reload this page.
-
BetaWas this translation helpful?Give feedback.
All reactions
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
-
No, it wasn't the |
BetaWas this translation helpful?Give feedback.
All reactions
-
Sorry, I got it wrong. I have deleted the comment |
BetaWas this translation helpful?Give feedback.
All reactions
😕 1
-
If you don't want to use Reactivity Transform anymore, here is a tool that helps you drop reactivity transform in seconds. |
BetaWas this translation helpful?Give feedback.
All reactions
👍 2
-
Having to constantly deal with |
BetaWas this translation helpful?Give feedback.
All reactions
-
Thats your opinion. I dont mind it at all. It gives me a clear sign where something is coming from. Hence I like it |
BetaWas this translation helpful?Give feedback.
All reactions
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
-
I agree. That's why I avoid conststate=reactive({names:[]asstring[];}); Then we don't need state.names.push('Joe'); That's said, this reactivity macro was not good. I'm glad it was dropped. |
BetaWas this translation helpful?Give feedback.
All reactions
-
I don't see how |
BetaWas this translation helpful?Give feedback.
All reactions
👍 2
-
flutter_hooks, the most used state management package in flutter, is similar in principle to react hooks, but has a policy of updating by .value. flutter also has signal, which is also based on .value. I feel that libraries that update with setState() are rather rare nowadays. |
BetaWas this translation helpful?Give feedback.