-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Built-in Error/SuspenseBoundaries for React DecoratorNodes #3178
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Fixes #3089 |
@@ -31,6 +31,7 @@ | |||
"prettier": "^2.3.2", | |||
"react": "^18.2.0", | |||
"react-dom": "^18.2.0", | |||
"react-error-boundary": "^3.1.4", |
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.
QQ: is this one required, given default value is some sort of cope of react-error-boundary?
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.
Yeah, but it is just for the playground; other people can just their own replacement
It happens. Your video component crashes; or your component comes with some asynchronous GraphQL behavior that makes the component suspend. Both of them currently need developer awareness as otherwise it can break the whole editor (yes, not having a Suspense layer on a Decorator makes React swallow all the DOM).
We can make this better on our
@lexical/react
framework. We can ship this by default. And that's exactly what this PR fixes.Screen.Recording.2022-10-13.at.2.48.20.pm.mov
API
TypeScript
Flow and WWW
Or just simply (because it doesn't require fallback) -- don't really endorse this
Why custom ErrorBoundary component support but not for Suspense?
ErrorBoundary is a must have. Users shouldn't have to understand about error propagation on nested editor and the private
editor._onError
property.At the same time, Suspense is a fairly common user-visible state and it's a good practice to customize the glimmer to adjust the UI best. This can be done easily by adding another Suspense layer on the app. However, this one will act as a fallback mechanism in case the user didn't.
It is unwise to have ErrorBoundaries with a fallback to
null
. For newcomers, we may want to provide a built-in way to postpone this effort and simplify it. We can iterate on this later.react-error-boundary
thinks the same way:Second, we don't want to ship an opinionated implementation of React Error Boundary, just like React never did. For WWW, we have a internal-specific ErrorBoundary that we certainly want to reuse.
Kudos to @fantactuka for the ErrorBoundary idea