-
Notifications
You must be signed in to change notification settings - Fork 49.9k
Description
The provided repro is a contrived example, but a common example of where this is unexpected is if you were using Activity to render a previously visited page, and that page rendered a hook that throws an error if it's missing some sort of context.
In the case of Next.js, imagine we're grabbing route params via useParams, and we navigate to a route that no longer has that param available. When that subtree is switched to "hidden" mode, if any of the containing hooks/components threw an error when a param value is unavailable, that error would be triggered when navigating to the different page.
React version: 19.2.0
Steps To Reproduce
- Render an
<Activity>boundary in "hidden" mode, and have it throw an error - Observe that even though the containing component is hidden, the error escapes and causes an error while rendering the "Visible" element.
Link to code example: https://codesandbox.io/p/devbox/distracted-poitras-yd3dkt
The current behavior
Throwing an error inside of a "hidden" Activity boundary triggers an error.
The expected behavior
Throwing an error inside of a "hidden" Activity boundary should only trigger the error when the boundary is visible.