-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Description
Core or SDK?
Platform/SDK
Which part? Which one?
Javascript / React
Description
The fallback prop of the ErrorBoundary accepts a React.ReactNode (or function that returns one), but the body of the render method checks for isValidElement (see:
sentry-javascript/packages/react/src/errorboundary.tsx
Lines 163 to 165 in 316566e
| if (React.isValidElement(fallback)) { | |
| return fallback; | |
| } |
The docs suggest that a string (ReactNode) can be passed in, but the ErrorBoundary will render null.
Note that if you supply a function for fallback that returns a ReactNode (eg. string), it will actually render because there is no check for isValidElement around the fallback function variant.
Suggested Solution
The solution depends on the preference.
Personally, I think it should be an element. If that's the consensus, we should update the typings in sentry-javascript and the docs to reflect that.
If it should be a ReactNode, then we need to remove the isValidElement check.
Happy to implement either solution! Either way, we should include a new test for this in sentry-javascript.