Skip to content

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

Merged
merged 4 commits into from
Jan 24, 2023

Conversation

manudeli
Copy link
Member

@manudeli manudeli commented Jan 24, 2023

feat(error-boundary): add withErrorBoundary for consistency

  1. add withAsyncBoundary's displayName for development mode
  2. add withErrorBoundary like withAsyncBoundary of @toss/async-boundary

Why add displayName in this Pull Request

🔗 Convention: Wrap the Display Name for Easy Debugging in react-docs

PR Checklist

  • I read and included theses actions below
  1. I have read the Contributing Guide
  2. I have written documents and tests, if needed.

@netlify
Copy link

netlify bot commented Jan 24, 2023

👷 Deploy request for slash-libraries pending review.

Visit the deploys page to approve it

Name Link
🔨 Latest commit 18fddb4

@manudeli manudeli changed the title feat(withAsyncBoundary): add withAsyncBoundary's display for development mode feat(error-boundary): add withErrorBoundary for consistency Jan 24, 2023
Comment on lines +15 to +18
if (process.env.NODE_ENV !== 'production') {
const name = Component.displayName || Component.name || 'Component';
Wrapped.displayName = `withAsyncBoundary(${name})`;
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. add withAsyncBoundary's displayName for development mode

Comment on lines +5 to +21
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;
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. add withErrorBoundary like withAsyncBoundary of @toss/async-boundary

@raon0211 raon0211 changed the title feat(error-boundary): add withErrorBoundary for consistency feat(error-boundary): add withErrorBoundary for consistency, and add displayName in development mode Jan 24, 2023
Copy link
Collaborator

@raon0211 raon0211 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@raon0211 raon0211 merged commit 25f43a9 into toss:main Jan 24, 2023
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