You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The babel-sugar-setup-ref plugin only works inside the setup() function. This is problematic because when common logic is extracted into composable units in other functions, code can break silently, and without having any visible functional differences to working code.
The big problem is that this difference is completely invisible to the developer - no compile errors, no console warnings, no obvious difference in code. This took me hours to debug, and I imagine plenty of other developers will also hit this case.
There are a few possible ways I can see this could be fixed:
Rewrite ref={something} everywhere, not just in the setup method
Emit a compile-time warning when ref={something} is seen outside of the setup method
Instead of detecting and modifying ref={} at compile time, wrap the return value of setup() with a function that walks the returned VNode tree and replaces ref values at run time
Instead of detecting and modifying ref={} at compile time, wrap h/createElement so that it automatically converts refs
The text was updated successfully, but these errors were encountered:
Related issue: vuejs/composition-api#91
The
babel-sugar-setup-ref
plugin only works inside thesetup()
function. This is problematic because when common logic is extracted into composable units in other functions, code can break silently, and without having any visible functional differences to working code.E.g. this works:
But if you try to extract the logic,
visibilitySensorEl
staysnull
and nothing works:The big problem is that this difference is completely invisible to the developer - no compile errors, no console warnings, no obvious difference in code. This took me hours to debug, and I imagine plenty of other developers will also hit this case.
There are a few possible ways I can see this could be fixed:
ref={something}
everywhere, not just in thesetup
methodref={something}
is seen outside of thesetup
methodref={}
at compile time, wrap the return value ofsetup()
with a function that walks the returned VNode tree and replacesref
values at run timeref={}
at compile time, wraph
/createElement
so that it automatically convertsref
sThe text was updated successfully, but these errors were encountered: