When referencing components, can I use shadowRef
instead of ref
?
#6894
-
From Document: It use
Would it be better to use The same happens in the const elRef = ref<HTMLElement | null>(null) The expected return type is:
The actually return type is: const elRef: Ref<{
accessKey: string;
readonly accessKeyLabel: string;
autocapitalize: string;
dir: string;
draggable: boolean;
hidden: boolean;
inert: boolean;
innerText: string;
lang: string;
readonly offsetHeight: number;
... 276 more ...;
focus: (options?: FocusOptions | undefined) => void;
} | null> This issue has been fixed at #3791 . |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments 8 replies
-
the |
Beta Was this translation helpful? Give feedback.
-
Anyone any update on this? Should we be using |
Beta Was this translation helpful? Give feedback.
-
I always use |
Beta Was this translation helpful? Give feedback.
-
It seems that So if the demo is correct, it's perfectly fine to use ===== UPDATE =========== I made another playground using component template refs, one with |
Beta Was this translation helpful? Give feedback.
-
Yeah, they behave similar in this case. Vue doesn't make a proxy out of DOM elements. I always use core/packages/reactivity/src/ref.ts Line 155 in f66a75e core/packages/reactivity/src/reactive.ts Line 242 in f66a75e core/packages/reactivity/src/reactive.ts Line 269 in f66a75e core/packages/reactivity/src/reactive.ts Line 37 in f66a75e |
Beta Was this translation helpful? Give feedback.
the
shallowRef
is better thanref
fortemplate refs
.