-
Notifications
You must be signed in to change notification settings - Fork 4.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
Catch nested blocks preview errors #14767
Conversation
}; | ||
} | ||
|
||
componentDidCatch() { |
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.
Our goal is for Hooks to cover all use cases for classes as soon as possible. There are no Hook equivalents to the uncommon
getSnapshotBeforeUpdate
andcomponentDidCatch
lifecycles yet, but we plan to add them soon.
😿
/> | ||
</Disabled> | ||
); | ||
export class BlockPreviewContent extends Component { |
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 file contains 2 components. Wouldn't it better to handle this error in the parent BlockPreview
component and don't review this part of UI at all?
Aside: it might be nice to split this into two files.
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.
Actually, I think it's better to handle as closely as possible to the error. That way the "title" of the preview is still shown properly and just the content is left empty.
This seems to work fine for columns, but seeing an unusual issue when I test this on the
I'm seeing the error thrown in the console, but the |
That's fine I think. I guess this is the default behavior of componentDidCatch
@talldan Interesting, it feels like the focus is moving somewhere we display the preview |
closing in favor of #15561 which I think is a better fix. |
closes #9897
This is a stopgap solution for block style variations for blocks using InnerBlocks. At the moment, rendering innerBlocks in a preview doesn't work. Details here #9897 (comment)
The solution for the root issue is a little bit complex and might require using a nested editor.
In the meantime, this is a stop-gap solution that avoid rendering the preview if it triggers an error.
Testing instructions