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

ReferenceError: h is not defined #3449

Closed
yi-ge opened this issue Apr 19, 2018 · 4 comments
Closed

ReferenceError: h is not defined #3449

yi-ge opened this issue Apr 19, 2018 · 4 comments

Comments

@yi-ge
Copy link
Contributor

yi-ge commented Apr 19, 2018

Bug or support request summary

I use @storybook/cli@4.0.0-alpha.3.

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.

Steps to reproduce

1、yarn global add @storybook/cli@4.0.0-alpha.3
2、getstorybook

Please specify which version of Storybook and optionally any affected addons that you're running

  • @storybook/cli 4.0.0-alpha.3
  • @storybook/vue 4.0.0-alpha.3

Affected platforms

Mac Os

@stale
Copy link

stale bot commented May 10, 2018

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!

@stale stale bot added the inactive label May 10, 2018
@stale
Copy link

stale bot commented Jun 9, 2018

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!

@stale stale bot closed this as completed Jun 9, 2018
@tunaranch
Copy link

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>' }
})

@LazaroOnline
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants