mirror of
https://github.com/ragestudio/comty.git
synced 2025-06-09 10:34:17 +00:00
added ErrorBoundary
This commit is contained in:
parent
db71887ba5
commit
17ff2b986d
35
packages/app/src/components/ErrorBoundary/index.jsx
Normal file
35
packages/app/src/components/ErrorBoundary/index.jsx
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
import React from "react"
|
||||||
|
|
||||||
|
class ErrorBoundary extends React.Component {
|
||||||
|
state = {
|
||||||
|
error: null,
|
||||||
|
}
|
||||||
|
|
||||||
|
static getDerivedStateFromError(error) {
|
||||||
|
return { error: error }
|
||||||
|
}
|
||||||
|
|
||||||
|
render() {
|
||||||
|
if (this.state.error) {
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
style={{
|
||||||
|
display: "flex",
|
||||||
|
flexDirection: "column",
|
||||||
|
backgroundColor: "var(--background-color-accent)",
|
||||||
|
gap: "20px",
|
||||||
|
padding: "10px",
|
||||||
|
borderRadius: "14px",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<h3>Render Error</h3>
|
||||||
|
<code>{this.state.error.stack}</code>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.props.children
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default ErrorBoundary
|
Loading…
x
Reference in New Issue
Block a user