-
Notifications
You must be signed in to change notification settings - Fork 100
using useContext() causes error "Error: This must be called within a setup function." #643
Comments
BREAKING CHANGE: Some of the API and behaviour differ between Vue 2.7 and `@vue/composition-api`. In addition, there are some composition utilites that are no longer exported from `@nuxtjs/composition-api`, such as `defineAsyncComponent`, `warn`, etc. Please read https://blog.vuejs.org/posts/vue-2-7-naruto.html for the announcement and more information. resolves #644, resolves #643, resolves #593, resolves #19
This fixes compatibility bug for Vue 2.7: nuxt-community/composition-api#643
@danielroe When will this fix be available in a general 2.5.x release? |
What do you mean? |
@danielroe We have lots of projects that now break if we delete our package-lock.json and try to rebuild. ( Due to this issue ). I need to know what versions to point our package.json to so that we will pick up the fix - that closed this issue. |
This fix is available in "^0.33.0". |
@danielroe How do I fix this for the older 2.5.x versions? |
I'm not really sure what your problem is. Maybe open a new issue with a minimal reproduction? |
@danielroe I think my origin report should work. Just going to the Nuxt 2 site (docs ) and create a new project as I have highlighted above, installing the @nuxtjs/composition-api, then adding the following in the setup. This problem is in existing nuxt 2 projects - not Nuxt 3 or the bridge.
|
It works fine: https://stackblitz.com/edit/github-k8mxkn |
@danielroe @xicri I was able to get one of my other projects working by copying the dependencies from the fresh project over to the older one. Thanks for sticking with me. |
This fixes compatibility bug for Vue 2.7: nuxt-community/composition-api#643
This fixes compatibility bug for Vue 2.7: nuxt-community/composition-api#643
This fixes compatibility bug for Vue 2.7: nuxt-community/composition-api#643
I am still experiencing that issue with composition-api v 0.33.1 :( I tested with a blank project and that works fine... but not in my existing project. This is a production app, so i cannot just start from scratch... |
I have the same issue |
I had the same issue, but was due to the use of "useContext()" in a pinia store. |
Operating system: OS/X
Node-version: 14.18.2
npm version: 6.14.15
Using useContext in page setup function causes:
"Error: This must be called within a setup function."
1). Create new project via: npx create-nuxt-app
2). npm install @nuxtjs/composition-api --save
3). Add to buildModules in nuxt.config.js
{
buildModules: [
'@nuxtjs/composition-api/module'
]
}
The text was updated successfully, but these errors were encountered: