[GIFs] Add error boundary to GIF picker (#3643)

* error boundary on gif picker

* add dialog.close for web users

* fix size of dialog on web

* Safer coercion

---------

Co-authored-by: Dan Abramov <dan.abramov@gmail.com>
This commit is contained in:
Samuel Newman 2024-04-22 22:07:48 +01:00 committed by GitHub
parent 27c4054fcb
commit f4e72cc83c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 45 additions and 4 deletions

View file

@ -1,12 +1,14 @@
import React, {Component, ErrorInfo, ReactNode} from 'react'
import {msg} from '@lingui/macro'
import {useLingui} from '@lingui/react'
import {logger} from '#/logger'
import {ErrorScreen} from './error/ErrorScreen'
import {CenteredView} from './Views'
import {msg} from '@lingui/macro'
import {logger} from '#/logger'
import {useLingui} from '@lingui/react'
interface Props {
children?: ReactNode
renderError?: (error: any) => ReactNode
}
interface State {
@ -30,6 +32,10 @@ export class ErrorBoundary extends Component<Props, State> {
public render() {
if (this.state.hasError) {
if (this.props.renderError) {
return this.props.renderError(this.state.error)
}
return (
<CenteredView style={{height: '100%', flex: 1}}>
<TranslatedErrorScreen details={this.state.error.toString()} />