diff --git a/src/guide/extras/render-function.md b/src/guide/extras/render-function.md index 2bd0be44cc..344ce2b5af 100644 --- a/src/guide/extras/render-function.md +++ b/src/guide/extras/render-function.md @@ -706,36 +706,39 @@ If the directive is registered by name and cannot be imported directly, it can b
-With the Composition API, template refs are created by passing the `ref()` itself as a prop to the vnode: +With the Composition API, when using [`useTemplateRef()`](/api/composition-api-helpers#usetemplateref) template refs are created by passing the string value as prop to the vnode: ```js -import { h, ref } from 'vue' +import { h, useTemplateRef } from 'vue' export default { setup() { - const divEl = ref() + const divEl = useTemplateRef('my-div') - //
- return () => h('div', { ref: divEl }) + //
+ return () => h('div', { ref: 'my-div' }) } } ``` -or (with version >= 3.5) +
+Usage before 3.5 + +In versions before 3.5 where useTemplateRef() was not introduced, template refs are created by passing the ref() itself as a prop to the vnode: ```js -import { h, useTemplateRef } from 'vue' +import { h, ref } from 'vue' export default { setup() { - const divEl = useTemplateRef('my-div') + const divEl = ref() //
- return () => h('div', { ref: 'my-div' }) + return () => h('div', { ref: divEl }) } } ``` - +