-
-
Notifications
You must be signed in to change notification settings - Fork 5.3k
docs: update example to useTemplateRef
#31458
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
As of Vue 3.5 useTemplateRef (vuejs.org/guide/essentials/template-refs#accessing-the-refs) is the way to reference a html element or component
|
WalkthroughThe changes update the method used to create and handle a template reference in a Vue component. Instead of using the default reactive reference created by calling Tip ⚡🧪 Multi-step agentic review comment chat (experimental)
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (2)
docs/3.api/1.components/1.client-only.md (2)
63-65
: Adopt the Vue 3.5 API withuseTemplateRef
The new import and initialisation of the template reference using
useTemplateRef
are implemented correctly. However, consider renamingmyRef
tonuxtWelcomeRef
to mirror the reference name used in the template (i.e.<NuxtWelcome ref="nuxtWelcomeRef" />
). This alignment will improve clarity and minimise potential confusion for future maintainers.
68-70
: Verify watch callback usage for the new template referenceThe updated watch function correctly observes the template reference and is configured to trigger only once when
<NuxtWelcome />
is mounted. For improved maintainability, it may be worthwhile to include a brief explanatory comment on why the{ once: true }
option is used.
useTemplateRef
📚 Description
As of Vue 3.5 useTemplateRef (vuejs.org/guide/essentials/template-refs#accessing-the-refs) is the way to reference a html element or component