Clarify event handler error docs#242
Conversation
|
@aurorascharff is attempting to deploy a commit to the Brian Vaughn's projects Team on Vercel. A member of the Team first needs to authorize it. |
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Updates the “Async user code errors” example and related documentation to emphasize that error boundaries don’t automatically catch errors from event handlers or async callbacks, and demonstrates forwarding those errors to the nearest boundary.
Changes:
- Updated the example to trigger async work in an effect and forward failures via
useErrorBoundary. - Renamed UI/docs copy from “Async errors” to “Event handler and async errors” across routes/README/generated docs.
- Regenerated search and example JSON artifacts to reflect the new wording/snippet.
Reviewed changes
Copilot reviewed 5 out of 9 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| src/routes/examples/AsyncUserCodeErrors.tsx | Refactors the example to wrap in an ErrorBoundary and forward async callback errors from useEffect. |
| src/routes/AsyncUserCodeErrorsRoute.tsx | Updates page title and explanatory copy to include event handler + async callback errors. |
| src/App.tsx | Updates nav label and warning copy to match the new wording. |
| lib/components/ErrorBoundary.tsx | Updates public JSDoc section header wording. |
| README.md | Renames the “Async errors” section and refreshes example copy/snippet. |
| public/generated/examples/AsyncUserCodeErrors.json | Regenerates the highlighted example HTML snippet. |
| public/generated/docs/ErrorBoundary.json | Regenerates docs content with updated section label. |
| public/generated/search-records.json | Regenerates searchable docs text with updated wording/snippet. |
| public/generated/search-index.json | Regenerates search index entries with updated wording/snippet. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
32d42ad to
5585642
Compare
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
| <NavLink path="/examples/error-logging">Error logging</NavLink> | ||
| <NavLink path="/examples/async-user-code-errors"> | ||
| Async user code errors | ||
| Event handler and async errors |
There was a problem hiding this comment.
Good catch! Looks like the layout breaks when i select it (because of the bold) even with the shorter version. So probably we should also fix the layout! Checking.
There was a problem hiding this comment.
I'll just make it slightly shorter to "events & async" to avoid changing your sidebar layout here
But I would love to freshen up the docs page app the future!
There was a problem hiding this comment.
If you have ideas for the docs page, let's chat about them over on https://github.com/bvaughn/react-lib-tools 😃 That project is just an internal set of scripts and styles etc that I put together to make it easier for me to release docs for a few of my React component libs like this.
| fetchUserProfile(username).catch((error) => { | ||
| if (!cancelled) { | ||
| showBoundary(error); | ||
| } | ||
| }); |
There was a problem hiding this comment.
I think the change back to an effect+fetch is probably a good one here, but I wonder if we should show more than just the error path? (Currently the fetch discards the successful value so the docs example looks a bit incomplete.)
The original example had a comment placeholder:
useEffect(() => {
fetchGreeting(username).then(
(response) => {
// Set data in state and re-render ...
response; // hidden
},
(error) => {
// Show error boundary
showBoundary(error);
}
);
});Maybe we should (re)add that?
bvaughn
left a comment
There was a problem hiding this comment.
I like these changes! 👍🏼
Two small suggestions though.
5585642 to
93718e3
Compare



What
Clarifies the docs that
useErrorBoundaryis useful for event handler errors as well as async callback errors.Why
React error boundaries do not automatically catch errors from event handlers or async code that runs after render. The previous "async errors" wording was accurate but too narrow, because manually caught event handler errors can also be passed to the nearest boundary.
How
useErrorBoundaryexample to the commonuseEffect+ rejected fetch pattern.usernamechanges and ignore stale request failures after cleanup.useTransitionexample focused on a mutation-style Action.