bvaughn/react-error-boundary — reverse-engineered prompt

Reverse engineered prompt

GitHub

Build me a small reusable React library that makes it easy for app developers to catch render errors and show a friendly fallback screen instead of crashing the whole app.

I want an ErrorBoundary component that can wrap any part of a React tree. If something below it throws while rendering, it should show either simple fallback content, a custom fallback component, or a render function that gets the error and a retry button function. It should support resetting after an error, including when reset keys change, and it should call optional handlers when an error happens or when the boundary resets.

Also include a helper for getting a safe error message, and a hook or simple pattern for sending async errors to the nearest boundary. Please write it in TypeScript, include tests for the main behavior, and add a basic demo page plus clear README examples showing how someone would use it in a normal React app.

Want more depth? Deep Reverse