Extract Vue component props to another file will be ignored by Storybook.
See original GitHub issueDescribe the bug
If you write Vue component’s props in another file, and then import it and spread it to the props
property section, Storybook won’t be able to detect those props.
To Reproduce
vue create sb6-test
with TypeScript templatecd sb6-test
npx sb@next init
- create two files
HelloWorldButton.vue
<template>
<button :disabled="disabled">Hello World</button>
</template>
<script lang="ts">
import Vue from "vue";
export default Vue.extend({
props: {
disabled: Boolean,
},
});
</script>
HelloWorldButton.stories.ts
import HelloWorldButton from "./HelloWorldButton.vue";
export default {
title: "HelloWorldButton",
component: HelloWorldButton,
};
export const Normal = (_: any, { argTypes }: any) => ({
props: Object.keys(argTypes),
components: { HelloWorldButton },
template: `
<HelloWorldButton v-bind="$props" />
`,
});
Now everything looks fine
However, if you extract those props like this
<template>
<button :disabled="disabled">Hello World</button>
</template>
<script lang="ts">
import Vue from "vue";
import { PropValidator } from "vue/types/options";
const props = {
disabled: Boolean as PropValidator<boolean>,
};
export default Vue.extend({
props: {
...props,
},
});
</script>
Now the Storybook can’t detect those props right now.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:2
- Comments:7 (3 by maintainers)
Top Results From Across the Web
Args - Storybook - JS.ORG
Args can be used to dynamically change props, slots, styles, inputs, etc. It allows Storybook and its addons to live edit components. You...
Read more >Avoid mutating a prop directly since the value will be overwritten
I want my components to mutate props. I don't want the complexity of Vuex/boilerplate code emitting hundreds of events. But that's not the...
Read more >Documenting components - Vue Styleguidist
In some rare cases, you might want to remove a prop from the documentation while keeping it in the code. The @ignore tag...
Read more >Server-Side Rendering (SSR) - Vue.js
We will be using express for the next steps: Run npm install express; Create the following server.js file: js
Read more >Dynamic behavior in Svelte: working with variables and props
svelte component will accept a todos attribute, which when omitted will be initialized to an empty array. Have a look at the app,...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Hello @stefashkaa
Thank you for taking the time to explain your use case. Everything should indeed be working fine here, but you found a bug. I will be fixing it soon.
@elevatebart do you have more info on what the bug might be? I’m seeing this error still in the latest storybook and vue3.
cheers