Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Show a meaningful error on missing element #532

Closed
gaearon opened this issue Oct 5, 2016 · 2 comments
Closed

Show a meaningful error on missing element #532

gaearon opened this issue Oct 5, 2016 · 2 comments

Comments

@gaearon
Copy link

gaearon commented Oct 5, 2016

Can you spot a mistake here?

storiesOf('App', module)
  .add('normal', () => {
    <App />
  });

I used { instead of (, and so didn’t return anything.
As a result, I got this error:

screen shot 2016-10-05 at 11 47 29

I think Storybook should validate elements before passing them to React. If element is undefined, it should throw something like "Expected the function in storiesOf().add(...) to return a React element. Instead it returned undefined. Did you forget the return statement?"

Similarly, if element.type is undefined, print something like "Expected the function in storiesOf().add(...) to return a valid React element. However, element's type is undefined. If you imported that component without the curly braces, verify that it was exported with an "export default" syntax."

@arunoda
Copy link
Member

arunoda commented Oct 5, 2016

This is pretty great.
And I think many people would have met with this error.
I can do a fix.

@arunoda
Copy link
Member

arunoda commented Oct 5, 2016

Fixed with v2.22.0

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants