Skip to content
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

Open
6 tasks done
CIB opened this issue Jan 22, 2024 · 3 comments
Open
6 tasks done
Labels
to triage This issue needs to be triaged

Comments

@CIB
Copy link

CIB commented Jan 22, 2024

Describe the bug

When using provide from a nuxt plugin, and inserting the provided value into a component using useNuxtApp, 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:

  return {
    provide: {
      example: { foo: 'bar' },
    },
  };

In components/test.vue

const nuxtApp = useNuxtApp();
const foo = nuxtApp.$example.foo;

Then try to start histoire dev with a story that includes <Test />, and an error will be thrown that nuxtApp.$example is undefined.

System Info

System:
    OS: Linux 5.0 undefined
    CPU: (8) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
    Memory: 0 Bytes / 0 Bytes
    Shell: 1.0 - /bin/jsh
  Binaries:
    Node: 18.18.0 - /usr/local/bin/node
    Yarn: 1.22.19 - /usr/local/bin/yarn
    npm: 10.2.3 - /usr/local/bin/npm
    pnpm: 8.14.0 - /usr/local/bin/pnpm
  npmPackages:
    @histoire/plugin-nuxt: ^0.17.8 => 0.17.8 
    @histoire/plugin-vue: ^0.17.8 => 0.17.8 
    histoire: ^0.17.8 => 0.17.8

Used Package Manager

npm

Validations

@CIB CIB added the to triage This issue needs to be triaged label Jan 22, 2024
Copy link

stackblitz bot commented Jan 22, 2024

Fix this issue in StackBlitz Codeflow Start a new pull request in StackBlitz Codeflow.

@dreitzner
Copy link

Same issue when using nuxtApp.provide('helpers', helpers); (which I guess has the same logic under the hood.

@positiveprogrammer
Copy link

This is because Histoire/plugin-next stub out useNuxtApp?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
to triage This issue needs to be triaged
Projects
None yet
Development

No branches or pull requests

3 participants