added ErrorBoundary

This commit is contained in:
SrGooglo 2025-03-13 23:34:58 +00:00
parent db71887ba5
commit 17ff2b986d

View 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