I use @storybook/[email protected].
const styles = {
textAlign: 'center',
};
let CenterDecorator = (storyFn) => (
<div style={styles}>
{ storyFn() }
</div>
)
storiesOf('Button', module)
.addDecorator(CenterDecorator)
.add('with text', () => ({
components: { MyButton },
template: '<my-button @click="action">Hello Button</my-button>',
methods: { action: action('clicked') },
}))
.add('with JSX', () => ({
components: { MyButton },
render(h) {
return <my-button onClick={this.action}>With JSX</my-button>;
},
methods: { action: linkTo('clicked') },
}))
I get the error: ReferenceError: h is not defined.
If add h in render, it work. #3409
But on the addDecorator, I cant get the h.
1、yarn global add @storybook/[email protected]
2、getstorybook
Mac Os
Hi everyone! Seems like there hasn't been much going on in this issue lately. If there are still questions, comments, or bugs, please feel free to continue the discussion. Unfortunately, we don't have time to get to every issue. We are always open to contributions so please send us a pull request if you would like to help. Inactive issues will be closed after 30 days. Thanks!
Hey there, it's me again! I am going close this issue to help our maintainers focus on the current development roadmap instead. If the issue mentioned is still a concern, please open a new ticket and mention this old one. Cheers and thanks for using Storybook!
Came across this error while trying to add a global decorator in my vue app.
Found something similar to this snippet after some digging, in case it helps someone else:
In my config.ts:
addDecorator(() => {
return { template: '<div id="app"><story/></div>' }
})
True, that works, as @tunaranch said.
Also if you want to use JSX instead of Vue Template string you also can, like this:
addDecorator(() =>
({ render() { return <div id="app"><story/></div>} })
)
The issue is that in Storybook with Vue you have to use the special component <story/> instead of the function parameter storyFn that is used in React projects, even if you are using JSX.
It would be nice if the official documentation reflected this and not just limit to React users.
Most helpful comment
Came across this error while trying to add a global decorator in my vue app.
Found something similar to this snippet after some digging, in case it helps someone else:
In my
config.ts: