mirror of
https://github.com/th30d4y/OpenLearnX.git
synced 2026-05-26 19:26:33 +00:00
update error
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
// components/ErrorBoundary.tsx
|
||||
import React from 'react'
|
||||
|
||||
class ErrorBoundary extends React.Component {
|
||||
constructor(props) {
|
||||
super(props)
|
||||
this.state = { hasError: false }
|
||||
}
|
||||
|
||||
static getDerivedStateFromError(error) {
|
||||
return { hasError: true }
|
||||
}
|
||||
|
||||
render() {
|
||||
if (this.state.hasError) {
|
||||
return <div>Something went wrong. Please refresh the page.</div>
|
||||
}
|
||||
|
||||
return this.props.children
|
||||
}
|
||||
}
|
||||
|
||||
// Wrap your app
|
||||
<ErrorBoundary>
|
||||
<YourApp />
|
||||
</ErrorBoundary>
|
||||
Reference in New Issue
Block a user