Skip to content

Add Error Boundary to useTransition API docs #6354

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

Merged
merged 18 commits into from
Oct 24, 2023

Conversation

kmiddleton14
Copy link
Contributor

@kmiddleton14 kmiddleton14 commented Oct 17, 2023

Error Boundary now works in React canary with useTransition API and displays the fallback. This PR adds documentation with a simple usage example.

Note that we want to prevent the error dialog from displaying in the Sandpack when we throw an error so that we can show the error boundary fallback.

Preview link

Screenshot 2023-10-17 at 5 01 53 PM
Monosnap.screencast.2023-10-17.15-23-20.mp4

@github-actions
Copy link

github-actions bot commented Oct 17, 2023

Size changes

📦 Next.js Bundle Analysis for react-dev

This analysis was generated by the Next.js Bundle Analysis action. 🤖

One Page Changed Size

The following page changed size from the code in this PR compared to its base branch:

Page Size (compressed) First Load
/[[...markdownPath]] 78.81 KB (🟢 -14 B) 182.55 KB
Details

Only the gzipped size is provided here based on an expert tip.

First Load is the size of the global bundle plus the bundle for the individual page. If a user were to show up to your website and land on a given page, the first load size represents the amount of javascript that user would need to download. If next/link is used, subsequent page loads would only need to download that page's bundle (the number in the "Size" column), since the global bundle has already been downloaded.

Any third party scripts you have added directly to your app using the <script> tag are not accounted for in this analysis

Next to the size is how much the size has increased or decreased compared with the base branch of this PR. If this percentage has increased by 10% or more, there will be a red status indicator applied, indicating that special attention should be given to this.

@sophiebits
Copy link
Member

I'm looking at this again and I'm worried this isn't realistic enough to be helpful. Do we really expect people to throw on purpose directly in a transition? Or should we be trying to explain what happens when there is an unhandled error.

Assuming the latter (which had been my assumption), can we make the code call some a function with a real product action name that ends up throwing? Like function addComment() {}. It can fail unconditionally but what we should be teaching IMO is how errors in normal code bubble up when that code fails.

@kmiddleton14
Copy link
Contributor Author

@sophiebits yes your assumption is correct it was more of a tool to demonstrate what happens with an unhandled error. That's a good point and I can update to be a more product specific example

kmiddleton14 and others added 3 commits October 20, 2023 11:47
Co-authored-by: Jan Kassens <jan@kassens.net>
Co-authored-by: Luna <lunaleaps@gmail.com>
Co-authored-by: Luna <lunaleaps@gmail.com>
@kmiddleton14
Copy link
Contributor Author

Not ready for review - had some merging issues and will resolve first

@lunaleaps lunaleaps changed the base branch from main to use-client October 24, 2023 00:05
@lunaleaps lunaleaps changed the base branch from use-client to main October 24, 2023 00:05
Co-authored-by: Luna <lunaleaps@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants