-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
fix(react): Add children prop type to ErrorBoundary component #4966
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
Changes from 3 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Hi @cameronaziz, thank you so much for submitting this PR. We would like to fix this type error and release a patch.
Would you be willing to get rid of the
React.PropsWithChildren
helper here and instead add achildren?: React.ReactNode
prop toErrorBoundaryProps
, just like one of the maintainers of react suggests here? If that's done we're good to go!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.
@lforst Are you thinking more on the direction of what my original commit was: ea99673
The issue was it would not build with the children render as a function.
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.
1a575e6 without the
| undefined
would be perfect imo.That should be fine typewise. Seems weird that it's not building. Can you update the code? I'll take a look at the build output afterwards.
Uh oh!
There was an error while loading. Please reload this page.
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.
I can, but that ends up making the
children
within this block anever
.sentry-javascript/packages/react/src/errorboundary.tsx
Lines 153 to 155 in cafec74
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.
You're right. Apparently
@types/react@18
changed theReactNode
type not to be callable anymore. I think up to v17 it had a constructor type of some sort. For me, when using the types from@type/react@18
neitherchildren?: ReactNode
norReact.PropsWithChildren
works. I think it's best if we go with the changes from ea99673.Sorry for flip-flopping around. Thank you very much for helping out 🙏