mirror of
https://github.com/EnixCoda/Gitako.git
synced 2026-03-11 08:54:44 +00:00
feat: ErrorBoundary
This commit is contained in:
parent
26d0b189bc
commit
d830741968
2 changed files with 18 additions and 10 deletions
12
src/components/ErrorBoundary.tsx
Normal file
12
src/components/ErrorBoundary.tsx
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
import { raiseError } from 'analytics'
|
||||
import * as React from 'react'
|
||||
|
||||
export class ErrorBoundary extends React.PureComponent {
|
||||
componentDidCatch(error: Error, errorInfo: React.ErrorInfo) {
|
||||
raiseError(error, errorInfo)
|
||||
}
|
||||
|
||||
render() {
|
||||
return this.props.children
|
||||
}
|
||||
}
|
||||
|
|
@ -1,20 +1,16 @@
|
|||
import { raiseError } from 'analytics'
|
||||
import { SideBar } from 'components/SideBar'
|
||||
import { ConfigsContext, ConfigsContextWrapper } from 'containers/ConfigsContext'
|
||||
import * as React from 'react'
|
||||
import { ErrorBoundary } from './ErrorBoundary'
|
||||
|
||||
export class Gitako extends React.PureComponent {
|
||||
componentDidCatch(error: Error, errorInfo: React.ErrorInfo) {
|
||||
raiseError(error, errorInfo)
|
||||
}
|
||||
|
||||
render() {
|
||||
return (
|
||||
export function Gitako() {
|
||||
return (
|
||||
<ErrorBoundary>
|
||||
<ConfigsContextWrapper>
|
||||
<ConfigsContext.Consumer>
|
||||
{configContext => configContext && <SideBar configContext={configContext} />}
|
||||
</ConfigsContext.Consumer>
|
||||
</ConfigsContextWrapper>
|
||||
)
|
||||
}
|
||||
</ErrorBoundary>
|
||||
)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue