Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Oct 15, 2025

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 queryOptions from @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-query queryOptions

Possible Solution

No response

etc.

No response</issue_description>

Comments on the Issue (you are @copilot in this section)

Fixes #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.

@changeset-bot
Copy link

changeset-bot bot commented Oct 15, 2025

⚠️ No Changeset found

Latest commit: c174f9c

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

@vercel
Copy link

vercel bot commented Oct 15, 2025

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

Project Deployment Preview Comments Updated (UTC)
v2.suspensive.org Ready Ready Preview Comment Oct 24, 2025 8:22am
v3.suspensive.org Ready Ready Preview Comment Oct 24, 2025 8:22am
visualization.suspensive.org Ready Ready Preview Comment Oct 24, 2025 8:22am

@coauthors
Copy link

coauthors bot commented Oct 24, 2025

People can be co-author:

Candidate Reasons Count Add this as commit message
@Copilot #1788 1 Co-authored-by: Copilot <[email protected]>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: errorBoundaryProps util

2 participants