-
Notifications
You must be signed in to change notification settings - Fork 843
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
[FIX] Prevent Storybook code-snippet errors crashing the story preview #7874
Merged
mgadewoll
merged 3 commits into
elastic:main
from
mgadewoll:storybook/prevent-code-snippet-error-crashing-preview
Jul 10, 2024
Merged
[FIX] Prevent Storybook code-snippet errors crashing the story preview #7874
mgadewoll
merged 3 commits into
elastic:main
from
mgadewoll:storybook/prevent-code-snippet-error-crashing-preview
Jul 10, 2024
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- ensures code snippet errors don't crash the preview
cee-chen
reviewed
Jul 5, 2024
packages/eui/.storybook/addons/code-snippet/decorators/jsx_decorator.tsx
Outdated
Show resolved
Hide resolved
cee-chen
reviewed
Jul 5, 2024
packages/eui/.storybook/addons/code-snippet/decorators/jsx_decorator.tsx
Outdated
Show resolved
Hide resolved
cee-chen
reviewed
Jul 5, 2024
packages/eui/.storybook/addons/code-snippet/decorators/jsx_decorator.tsx
Outdated
Show resolved
Hide resolved
- renames useEffect to useStorybook effect to prevent confusion between React and Javascript context - removes obsolete useCallback and variable reset
💚 Build Succeeded
History
|
cee-chen
reviewed
Jul 8, 2024
import { addons, useEffect, useCallback } from '@storybook/preview-api'; | ||
import { | ||
addons, | ||
useEffect as useStorybookEffect, |
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.
🤦 Thank you so much for the rename! I totally missed originally that this wasn't actually React's useEffect
.
cee-chen
approved these changes
Jul 8, 2024
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.
👏 This is fantastic! thanks again Lene!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
documentation
Issues or PRs that only affect documentation - will not need changelog entries
skip-changelog
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds an additional
try/catch
wrapper on the main functionality of the Storybookcode-snippet
addon to prevent any potential errors in the code snippet from crashing the Storybook preview and making local development impossible. The addon will return no code snippet if an error occurred and log the error to the console.This does not actually affect any story currently but would be an issue if code is changed/added to a version that the code snippet doesn't support yet. E.g. the functionality to resolve the Emotion
css
prop is currently not fully supporting all cases, and can break otherwise.QA
There is not actual way to QA this in the existing Storybook