You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Composables should only be called synchronously in <script setup> or the setup() hook. In some cases, you can also call them in lifecycle hooks like onMounted().
What about using them outside?
I don't mean in component, where is script setup.
In my case I mean use them from Pinia actions.
It makes definitely sense to set cookie / call mutation from Pinia action.
Logic from other libraries are often exposed as composable (or are the most convenient to use it as composable)
For example Nuxt's useCookie or composables shortcuts generated from graphql-generator-urql (useFooQuery etc.)
(and Urql has also guard disallowing when called outside context, raising use* functions may only be called during the setup() ... error)
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Official documentation says
Composables should only be called synchronously in <script setup> or the setup() hook. In some cases, you can also call them in lifecycle hooks like onMounted().
What about using them outside?
I don't mean in component, where is script setup.
In my case I mean use them from Pinia actions.
It makes definitely sense to set cookie / call mutation from Pinia action.
Logic from other libraries are often exposed as composable (or are the most convenient to use it as composable)
For example Nuxt's useCookie or composables shortcuts generated from graphql-generator-urql (useFooQuery etc.)
(and Urql has also guard disallowing when called outside context, raising use* functions may only be called during the
setup()
... error)Beta Was this translation helpful? Give feedback.
All reactions