added error boundary to playground
Pre-flight checklist
- [x] I have read the Contributing Guidelines on pull requests.
- [ ] If this is a code change: I have written unit tests and/or added dogfooding pages to fully verify the new behavior.
- [ ] If this is a new API or substantial change: the PR has an accompanying issue (closes #0000) and the maintainers have approved on my working plan.
Motivation
Fixes page crashing when typing undefined or {} in live editor
Test Plan
Test links
Deploy preview: https://deploy-preview-_____--docusaurus-2.netlify.app/
Related issues/PRs
#8009
Hi @rashidmya!
Thank you for your pull request and welcome to our community.
Action Required
In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.
Process
In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.
Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.
If you have received this in error or have any questions, please contact us at [email protected]. Thanks!
[V2]
| Name | Link |
|---|---|
| Latest commit | fd54f123fd2893ef017b0078028982895002d780 |
| Latest deploy log | https://app.netlify.com/sites/docusaurus-2/deploys/6348307e1bd1f50009097c52 |
| Deploy Preview | https://deploy-preview-8015--docusaurus-2.netlify.app |
| Preview on mobile | Toggle QR Code...Use your smartphone camera to open QR code link. |
To edit notification comments on pull requests, go to your Netlify site settings.
⚡️ Lighthouse report for the deploy preview of this PR
| URL | Performance | Accessibility | Best Practices | SEO | PWA | Report |
|---|---|---|---|---|---|---|
| / | 🟠 58 | 🟢 98 | 🟢 100 | 🟢 100 | 🟢 90 | Report |
| /docs/installation | 🟠 88 | 🟢 100 | 🟢 100 | 🟢 100 | 🟢 90 | Report |
Note, we already have an error boundary component in core: https://docusaurus.io/docs/docusaurus-core#errorboundary Please just reuse this one
using error boundary component in core results in this behavior inside the live editor. is that okay?
You should provide a custom fallback.
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!
Its working correctly now. any notes?
is this better?
I had difficulty figuring out how to reuse the LiveError component
@slorber why does CI fail when I added styles for the component
@slorber why does CI fail when I added styles for the component
The CI says it: you just added an extra ! in the tryAgain button label, and we end up with 2 buttons in our theme with the same key but different labels which we should avoid.
LGTM 👍 just did minor fixes
Note I tried to do some kind of "auto try again on code change" behavior but it's complicated because it seems const {code,error} = useContext(LiveContext) does not update for some reason when code string contains error, so the auto retry is hard to trigger with an effect.
Also we still have weird annoying cases where both the live error and the error boundary crash are displayed at the same time. Tried to improve but react-live does not make it very easy unfortunately
When code change from "crash" to "react-live-error" state, both are displayed. Unless we find a way to autoretry the error boundary I think it's better to display the live error in addition (even if it's weird) rather that staying on the rough error boundary crash message:
Those are edge cases, probably not worth investing a lot of time on these atm