bsky-app/src/view/com/util/ErrorBoundary.tsx
Ansh c5b6f88e9a
Hindi Internationalization (#1914)
* get basic hindi support to work

* get web app language switcher in

* Refactor i18n implementation and remove unused
code

* add missing strings

* add dropdowns and modals missing strings

* complete all hindi translations

* fix merge conflicts

* fix legeacy persisted state

* fix data in RecommendedFeeds

* fix lint
2023-11-20 13:29:27 -08:00

44 lines
1 KiB
TypeScript

import React, {Component, ErrorInfo, ReactNode} from 'react'
import {ErrorScreen} from './error/ErrorScreen'
import {CenteredView} from './Views'
import {t} from '@lingui/macro'
interface Props {
children?: ReactNode
}
interface State {
hasError: boolean
error: any
}
export class ErrorBoundary extends Component<Props, State> {
public state: State = {
hasError: false,
error: undefined,
}
public static getDerivedStateFromError(error: Error): State {
return {hasError: true, error}
}
public componentDidCatch(error: Error, errorInfo: ErrorInfo) {
console.error('Uncaught error:', error, errorInfo)
}
public render() {
if (this.state.hasError) {
return (
<CenteredView style={{height: '100%', flex: 1}}>
<ErrorScreen
title={t`Oh no!`}
message={t`There was an unexpected issue in the application. Please let us know if this happened to you!`}
details={this.state.error.toString()}
/>
</CenteredView>
)
}
return this.props.children
}
}