-
-
Notifications
You must be signed in to change notification settings - Fork 193
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
histoire-plugin-nuxt: provide from plugin not working with useNuxtApp in component #666
Comments
Start a new pull request in StackBlitz Codeflow. |
Same issue when using |
This is because Histoire/plugin-next stub out useNuxtApp? |
That's the problem. The stub could replicate a simple const nuxtApp = {
runWithContext: async fn => await fn(),
provide(key, value) {
const propertyName = '$' + key;
nuxtApp[propertyName] = value;
}
}
export const useNuxtApp = () => nuxtApp However, this doesn't completely solve the issue, because I'm seeing that plugins don't get access to the stubbed nuxtApp. So anything they provide still won't be available to components in histoire. export default defineNuxtPlugin(async (nuxtApp) => {
// nuxtApp here is not the stubbed one
}) export default defineNuxtPlugin(() => {
return {
// This is not going to interact with the stubbed nuxtApp
provide: {
img: useImage(),
},
}
}) I don't fully understand the context around why the decision was made to stub nuxtApp. If I disable it (by removing the @Akryum, @danielroe, or others. Some additional high-level info may help someone address the issue. Related: #710 |
Describe the bug
When using
provide
from a nuxt plugin, and inserting the provided value into a component usinguseNuxtApp
, the provided value will not be available, and an error will be thrown.Reproduction
Stackblitz: https://stackblitz.com/edit/nuxt-starter-7avtmp?file=components%2Ftest.vue
In
plugins/example.ts
:In
components/test.vue
Then try to start
histoire dev
with a story that includes<Test />
, and an error will be thrown thatnuxtApp.$example
isundefined
.System Info
Used Package Manager
npm
Validations
The text was updated successfully, but these errors were encountered: