Skip to content

fix(react): Require ReactElement in ErrorBoundary props and render #3857

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
Aug 3, 2021

Conversation

jcomo
Copy link

@jcomo jcomo commented Aug 1, 2021

Updates the ErrorBoundary fallback type in @sentry/react to require a ReactElement. This addresses the inconsistency in #3828

Open question: in the case where the fallback prop is not a valid element, I wanted to include some sort of console warning so that the developer can get feedback (really only matters for js). This would have saved us an hour of debugging and sifting through the SDK source code. However, the linter doesn't allow console.log statements -- what's the preferred approach? We can ignore the linter for that line, leave it out entirely, or follow some warning convention if it exists in the codebase.


Before submitting a pull request, please take a look at our
Contributing guidelines and verify:

  • If you've added code that should be tested, please add tests.
  • Ensure your code lints and the test suite passes (yarn lint) & (yarn test).

Copy link
Member

@AbhiPrasad AbhiPrasad left a comment

Choose a reason for hiding this comment

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

Nice. Thanks for taking this on!

Mind editing the PR title to add fix(react): ...? This matches our conventions and makes writing the changelog for releases much easier.

}

// Fail gracefully if no fallback provided
// Fail gracefully if no fallback provided or is not valid
Copy link
Member

Choose a reason for hiding this comment

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

We can use logger from @sentry/utils to log out a warning here: https://github.com/getsentry/sentry-javascript/blob/master/packages/utils/src/logger.ts

import { logger } from `@sentry/utils`

Copy link
Author

Choose a reason for hiding this comment

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

Perfect, thanks!

@jcomo jcomo changed the title Require ReactElement in ErrorBoundary props and render fix(react): Require ReactElement in ErrorBoundary props and render Aug 3, 2021
@jcomo
Copy link
Author

jcomo commented Aug 3, 2021

@AbhiPrasad should be all set for a final pass

Copy link
Member

@AbhiPrasad AbhiPrasad left a comment

Choose a reason for hiding this comment

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

Thank you!

@AbhiPrasad AbhiPrasad enabled auto-merge (squash) August 3, 2021 17:43
@AbhiPrasad AbhiPrasad merged commit 454893f into getsentry:master Aug 3, 2021
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