Skip to content

Fix ErrorBoundary retry mechanism with key-based remounting#7

Draft
Copilot wants to merge 3 commits intomasterfrom
copilot/test-functionality-and-repair-errors
Draft

Fix ErrorBoundary retry mechanism with key-based remounting#7
Copilot wants to merge 3 commits intomasterfrom
copilot/test-functionality-and-repair-errors

Conversation

Copy link

Copilot AI commented Feb 4, 2026

React Error Boundaries don't automatically remount child trees after state reset. The "Try Again" button was resetting internal state but React continued rendering the error UI because the errored component tree remained mounted.

Changes

  • ErrorBoundary component: Added resetKey state that increments on retry, wrapping children in <Fragment key={resetKey}> to force remount
  • ErrorBoundary test: Corrected test sequence to update props before triggering retry (avoiding re-throw during remount)
  • Type safety: Fixed componentStack null handling with nullish coalescing
  • .gitignore: Excluded /assets/js/css build artifacts

Example

// Before: Children remained in errored state after handleRetry()
return children;

// After: Key change forces React to unmount/remount child tree
return <React.Fragment key={resetKey}>{children}</React.Fragment>;

This also improves production behavior—the retry button now actually recovers from errors instead of remaining stuck in error state.

Original prompt

test functionality and repair errors


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 2 commits February 4, 2026 13:25
Co-authored-by: nexusct <19503275+nexusct@users.noreply.github.com>
Co-authored-by: nexusct <19503275+nexusct@users.noreply.github.com>
Copilot AI changed the title [WIP] Test functionality and repair errors Fix ErrorBoundary retry mechanism with key-based remounting Feb 4, 2026
Copilot AI requested a review from nexusct February 4, 2026 13:27
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.

2 participants