error boundary
This commit is contained in:
21
src/components/error-boundary.tsx
Normal file
21
src/components/error-boundary.tsx
Normal file
@@ -0,0 +1,21 @@
|
||||
import React from 'react'
|
||||
|
||||
export class ErrorBoundary extends React.Component {
|
||||
state = {
|
||||
error: false
|
||||
}
|
||||
|
||||
static getDerivedStateFromError() {
|
||||
return {
|
||||
error: true
|
||||
}
|
||||
}
|
||||
|
||||
render() {
|
||||
if (this.state.error) {
|
||||
return <h1>Something went wrong.</h1>
|
||||
}
|
||||
|
||||
return this.props.children
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user