Skip to content

Commit 129c27c

Browse files
docs: correct usage examples of useTemplateRef (#3031)
1 parent 524de31 commit 129c27c

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/guide/typescript/composition-api.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,7 @@ With Vue 3.5 and `@vue/language-tools` 2.1 (powering both the IDE language servi
376376
In cases where auto-inference is not possible, you can still cast the template ref to an explicit type via the generic argument:
377377

378378
```ts
379-
const el = useTemplateRef<HTMLInputElement>(null)
379+
const el = useTemplateRef<HTMLInputElement>('el')
380380
```
381381

382382
<details>
@@ -438,7 +438,7 @@ In cases where the exact type of the component isn't available or isn't importan
438438
import { useTemplateRef } from 'vue'
439439
import type { ComponentPublicInstance } from 'vue'
440440

441-
const child = useTemplateRef<ComponentPublicInstance | null>(null)
441+
const child = useTemplateRef<ComponentPublicInstance>('child')
442442
```
443443

444444
In cases where the component referenced is a [generic component](/guide/typescript/overview.html#generic-components), for instance `MyGenericModal`:
@@ -467,7 +467,7 @@ import { useTemplateRef } from 'vue'
467467
import MyGenericModal from './MyGenericModal.vue'
468468
import type { ComponentExposed } from 'vue-component-type-helpers'
469469
470-
const modal = useTemplateRef<ComponentExposed<typeof MyGenericModal>>(null)
470+
const modal = useTemplateRef<ComponentExposed<typeof MyGenericModal>>('modal')
471471
472472
const openModal = () => {
473473
modal.value?.open('newValue')

0 commit comments

Comments
 (0)