CatchError in Connect: Provide theme when rendering caught error#37006
CatchError in Connect: Provide theme when rendering caught error#37006
Conversation
| render() { | ||
| if (this.state.error) { | ||
| return ( | ||
| <Failed alignSelf={'baseline'} message={this.state.error.message} /> |
There was a problem hiding this comment.
FailedApp is equivalent to Failed, but it also adds StyledApp and StaticThemeProvider.
There was a problem hiding this comment.
Hmm, actually that's bad because in case of an error we render StyledApp twice (one time in App and one time in CatchError). I'm just going to move CatchError to the top of the hierarchy in App then.
There was a problem hiding this comment.
Could we also convert this file to TS while we are there?
There was a problem hiding this comment.
I'd rather spend time elsewhere since this is used only in a single place. I tried to quickly do mv web/packages/teleterm/src/ui/components/CatchError/CatchError.{j,t}sx, but there are issues with how children are typed in Props.
|
@ravicious See the table below for backport results.
|
Fixes part of #36936.
CatchErroracts as an error boundary. When it catches an error, it rendersFailedfromdesign/CardError.However, since about v13,
Failedassumes that a theme is provided throughThemeProvider.CatchErroris rendered at a place in the hierarchy whereThemeProvideris not available. This resulted inCatchErrorcrashing whenever it attempted to render a caught error.teleport/web/packages/teleterm/src/ui/App.tsx
Lines 34 to 42 in 1548a43
We already had a problem like this with
FailedAppwhich is rendered when an error is caught during the boot procedure of the app. We fixed that problem by usingStaticThemeProviderwithinFailedApp(#29046). That provider always returns the dark theme.This PR moves
FailedAppto a separate file so that it can be used in bothCatchErrorandboot.tsx. It then reusesFailedAppinCatchErrorso that the theme is provided when rendering a caught error. It also adds regression tests to make sure thatCatchErrorandFailedAppare rendered properly whenThemeProvideris not available.