[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:
parent
27c4054fcb
commit
f4e72cc83c
2 changed files with 45 additions and 4 deletions
|
@ -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()} />
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue