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
{{ message }}
This repository has been archived by the owner on Dec 5, 2024. It is now read-only.
I'm trying to use onGlobalSetup to refactor some global injections I have currently in default layout setup function.
If I call useContext directly or any custom composition function try to call it while inside the onGlobalSetup, it throws an error with: Cannot read property 'context' of undefined
From what I understand, onGlobalSetup is just running code inside the root component setup function. So it should be working with any composition API functions, not just provide.
Unless this is expected then I guess it should be documented maybe?
ℹ️ Additional context
The reason I need to call useContext is that I have a few other composable functions that do call useContext, for cookie parsing and setting up a graphql client and various other stuff.
I would love to contribute to fix this, but I haven't figured out how you populate the globalNuxt values yet.
The text was updated successfully, but these errors were encountered:
It gets populated by the module based on the settings the user has defined in their nuxt.config - though most people probably don't customise their global nuxt ($nuxt) to anything else.
🐛 The bug
I'm trying to use
onGlobalSetup
to refactor some global injections I have currently indefault
layoutsetup
function.If I call
useContext
directly or any custom composition function try to call it while inside theonGlobalSetup
, it throws an error with:Cannot read property 'context' of undefined
Failing here:
🛠️ To reproduce
Steps to reproduce the behavior:
plugins/setup.js
useContext
inside aonGlobalSetup
callbackReproduction link:
https://codesandbox.io/s/nice-moser-xv3y1?file=/plugins/setup.js
🌈 Expected behaviour
From what I understand,
onGlobalSetup
is just running code inside the root component setup function. So it should be working with any composition API functions, not justprovide
.Unless this is expected then I guess it should be documented maybe?
ℹ️ Additional context
The reason I need to call
useContext
is that I have a few other composable functions that do calluseContext
, for cookie parsing and setting up a graphql client and various other stuff.I would love to contribute to fix this, but I haven't figured out how you populate the
globalNuxt
values yet.The text was updated successfully, but these errors were encountered: