Skip to content

Clarify event handler error docs#242

Merged
bvaughn merged 2 commits into
bvaughn:mainfrom
aurorascharff:refresh-event-handler-error-docs
May 25, 2026
Merged

Clarify event handler error docs#242
bvaughn merged 2 commits into
bvaughn:mainfrom
aurorascharff:refresh-event-handler-error-docs

Conversation

@aurorascharff

@aurorascharff aurorascharff commented May 25, 2026

Copy link
Copy Markdown
Contributor

What

Clarifies the docs that useErrorBoundary is 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

  • Rename the relevant docs section and navigation from "async" to "event handler and async" errors.
  • Restore the useErrorBoundary example to the common useEffect + rejected fetch pattern.
  • Make the effect example recover when username changes and ignore stale request failures after cleanup.
  • Keep the React 19 useTransition example focused on a mutation-style Action.
  • Regenerate docs, example, and search artifacts.

@vercel

vercel Bot commented May 25, 2026

Copy link
Copy Markdown

@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.

@aurorascharff aurorascharff marked this pull request as ready for review May 25, 2026 09:22
Copilot AI review requested due to automatic review settings May 25, 2026 09:22

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread src/routes/examples/AsyncUserCodeErrors.tsx
Comment thread src/routes/examples/AsyncUserCodeErrors.tsx Outdated
Comment thread src/routes/AsyncUserCodeErrorsRoute.tsx Outdated
Comment thread src/routes/AsyncUserCodeErrorsRoute.tsx
@aurorascharff aurorascharff marked this pull request as draft May 25, 2026 09:26
@aurorascharff aurorascharff force-pushed the refresh-event-handler-error-docs branch from 32d42ad to 5585642 Compare May 25, 2026 09:29
@aurorascharff aurorascharff marked this pull request as ready for review May 25, 2026 09:32
@vercel

vercel Bot commented May 25, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
react-error-boundary Ready Ready Preview May 25, 2026 1:55pm

Comment thread src/App.tsx Outdated
<NavLink path="/examples/error-logging">Error logging</NavLink>
<NavLink path="/examples/async-user-code-errors">
Async user code errors
Event handler and async errors

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This particular change kind of breaks the layout:

Before After
Image Image

How would you feel about this instead?

Suggested change
Event handler and async errors
Events and async functions
Image

@aurorascharff aurorascharff May 25, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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!

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment on lines +21 to +25
fetchUserProfile(username).catch((error) => {
if (!cancelled) {
showBoundary(error);
}
});

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed!

@bvaughn bvaughn left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like these changes! 👍🏼

Two small suggestions though.

@aurorascharff aurorascharff force-pushed the refresh-event-handler-error-docs branch from 5585642 to 93718e3 Compare May 25, 2026 12:42
@aurorascharff aurorascharff marked this pull request as draft May 25, 2026 12:46
@aurorascharff aurorascharff marked this pull request as ready for review May 25, 2026 13:18
@bvaughn bvaughn merged commit 061b8bc into bvaughn:main May 25, 2026
5 of 6 checks passed
@aurorascharff aurorascharff deleted the refresh-event-handler-error-docs branch May 25, 2026 13:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants