-
-
Notifications
You must be signed in to change notification settings - Fork 9.3k
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
Addon-docs: Error handling for invalid Story id #7965
Conversation
This pull request is automatically deployed with Now. Latest deployment for this branch: https://monorepo-git-fork-atanasster-mdx-empty-story.storybook.now.sh |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@atanasster Thanks for this PR! It's the right idea, but I think the implementation needs work. Comments below.
examples/official-storybook/stories/addon-docs/addon-docs.stories.mdx
Outdated
Show resolved
Hide resolved
…e to hooks stories
@shilman added a |
Thanks @atanasster! So would you consider this a bugfix for the hooks support PR? If so, I'll try to get it merged tomorrow my time. |
@shilman yes it can be considered a fix for the hooks support and I think it should be merged. |
@atanasster I tried the latest version on this PR with a clean bootstrap and am seeing the following issues on the Docs tab in
The error in all crashes is: |
@shilman ouch, very sorry about that. It seems the exception handler might be too specific for your config and you might have a different exception name |
Sorry - a misspelling crept in - 'Invariant Violation' was spelled 'Invariant Violations'. Maybe I pressed ctrl+s to save the file or something, because it was working for me before. |
@atanasster no worries. Fixing the typo fixe the hooks issues on my machine. Thanks! However, i'm still seeing the following on Does it work on your machine? |
@shilman glad to hear it fixes the issue. As for the empty message, no it doesn't show here, I didn't re-add it (I just added a fix for the exception if storyFn was null) - since the empty messages were in the other file (Story.tsx I think?)instead of the InlineStory? |
Pushed again, can you check the wording of the message Removed the unused children /weird thing to say in anything but react programming :)/ Shouldn't the linter catch those btw? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@atanasster This is working well for me now, thanks for your patience!
I worry a little bit about the hardcoded hooks error--I wonder why can't we just call <StoryFn />
(equivalent to React.createElement
?) every time.
Also, why do we need the try/catch at all? Isn't the non-existent story handled by the check at the beginning of the function? |
@shilman |
What happens if we just always run |
|
lib/components/src/blocks/Story.tsx
Outdated
interface CommonProps { | ||
title: string; | ||
height?: string; | ||
id: string; | ||
} | ||
|
||
type InlineStoryProps = { | ||
storyFn: React.ElementType; | ||
storyFn: () => React.ElementType; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@atanasster Why not just make this React.ElementType
? It will clean up the typing below too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And you can do everything inline too
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks for the feedback - simplified the code now
Awesome! |
Issue: #7964
What I did
added a check for no children to Story.tsx
added an empty story example
How to test