mirror of
https://github.com/nuxt/nuxt.git
synced 2025-03-22 09:15:54 +00:00
docs: warn about ref unwrapping when providing refs from plugin (#25054)
This commit is contained in:
parent
b95163c7ca
commit
a62f2ba3e3
@ -200,6 +200,11 @@ const { $hello } = useNuxtApp()
|
||||
Note that we highly recommend using [`composables`](/docs/guide/directory-structure/composables) instead of providing helpers to avoid polluting the global namespace and keep your main bundle entry small.
|
||||
::
|
||||
|
||||
::callout{color="amber" icon="i-ph-warning-duotone"}
|
||||
**If your plugin provides a `ref` or `computed`, it will not be unwrapped in a component `<template>`.** :br
|
||||
This is due to how Vue works with refs that aren't top-level to the template. You can read more about it [in the Vue documentation](https://vuejs.org/guide/essentials/reactivity-fundamentals.html#caveat-when-unwrapping-in-templates).
|
||||
::
|
||||
|
||||
## Typing Plugins
|
||||
|
||||
If you return your helpers from the plugin, they will be typed automatically; you'll find them typed for the return of `useNuxtApp()` and within your templates.
|
||||
|
Loading…
Reference in New Issue
Block a user