-
Notifications
You must be signed in to change notification settings - Fork 305
feat(error-boundary): add withErrorBoundary for consistency, and add displayName in development mode #195
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
👷 Deploy request for slash-libraries pending review.Visit the deploys page to approve it
|
if (process.env.NODE_ENV !== 'production') { | ||
const name = Component.displayName || Component.name || 'Component'; | ||
Wrapped.displayName = `withAsyncBoundary(${name})`; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- add withAsyncBoundary's displayName for development mode
export default function withErrorBoundary<Props extends Record<string, unknown> = Record<string, never>>( | ||
Component: ComponentType<Props>, | ||
errorBoundaryProps: ComponentProps<typeof ErrorBoundary> | ||
) { | ||
const Wrapped = (props: Props) => ( | ||
<ErrorBoundary {...errorBoundaryProps}> | ||
<Component {...props} /> | ||
</ErrorBoundary> | ||
); | ||
|
||
if (process.env.NODE_ENV !== 'production') { | ||
const name = Component.displayName || Component.name || 'Component'; | ||
Wrapped.displayName = `withErrorBoundary(${name})`; | ||
} | ||
|
||
return Wrapped; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- add withErrorBoundary like withAsyncBoundary of @toss/async-boundary
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
feat(error-boundary): add withErrorBoundary for consistency
Why add displayName in this Pull Request
🔗 Convention: Wrap the Display Name for Easy Debugging in react-docs
PR Checklist