suspensive
suspensive copied to clipboard
feat: Add errorBoundaryProps utility function
Overview
This PR adds a new errorBoundaryProps utility function to @suspensive/react, similar to @tanstack/react-query's queryOptions helper. This utility simplifies the creation of reusable ErrorBoundary configurations with proper TypeScript type inference.
Closes #[issue_number]
What Changed
Added errorBoundaryProps - a simple identity function that takes ErrorBoundary props (without children) and returns them, providing better type inference and enabling reusable error boundary configurations.
Usage
Before
// Without type inference helper, types can be verbose
const fallback = ({ error, reset }: ErrorBoundaryFallbackProps<CustomError>) => (
<div>{error.message}</div>
)
<ErrorBoundary
fallback={fallback}
onError={(error) => console.error(error)}
shouldCatch={CustomError}
>
<MyComponent />
</ErrorBoundary>
After
// With errorBoundaryProps, create reusable configurations
const errorBoundary = errorBoundaryProps({
fallback: ({ error }) => <div>{error.message}</div>,
onError: (error) => console.error(error),
shouldCatch: CustomError,
})
<ErrorBoundary {...errorBoundary}>
<MyComponent />
</ErrorBoundary>
Benefits
- Type Safety: Provides better type inference for ErrorBoundary props
- Reusability: Makes it easy to define and share error boundary configurations across components
- Consistency: Follows the same pattern as
queryOptionsfrom@tanstack/react-query - Developer Experience: Reduces boilerplate and improves IntelliSense support
Testing
- Added 5 runtime tests covering all functionality
- Added 5 type tests ensuring proper TypeScript inference
- All 188 tests pass ✅
- Code coverage maintained at 96%
Implementation Details
The implementation is minimal and focused:
- 20 lines of code (including JSDoc documentation)
- No breaking changes
- Follows existing patterns in the codebase
- Full backward compatibility
Original prompt
This section details on the original issue you should resolve
<issue_title>[Feature]: errorBoundaryProps util</issue_title> <issue_description>### Package Scope
@suspensive/react
Description
I wanna get errorBoundaryProps util function like
@tanstack/react-queryqueryOptionsPossible Solution
No response
etc.
No response</issue_description>
Comments on the Issue (you are @copilot in this section)
Fixes toss/suspensive#1787
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.
⚠️ No Changeset found
Latest commit: c174f9c8580951779c41fd310908d907e79e95f9
Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.
This PR includes no changesets
When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types
Click here to learn what changesets are, and how to add one.
Click here if you're a maintainer who wants to add a changeset to this PR
The latest updates on your projects. Learn more about Vercel for GitHub.
| Project | Deployment | Preview | Comments | Updated (UTC) |
|---|---|---|---|---|
| v2.suspensive.org | Preview | Comment | Oct 24, 2025 8:22am | |
| v3.suspensive.org | Preview | Comment | Oct 24, 2025 8:22am | |
| visualization.suspensive.org | Preview | Comment | Oct 24, 2025 8:22am |
People can be co-author:
| Candidate | Reasons | Count | Add this as commit message |
|---|---|---|---|
| @Copilot | https://github.com/toss/suspensive/pull/1788 | 1 | Co-authored-by: Copilot <[email protected]> |