Fix images

This commit is contained in:
Prayag Prajapati committed 2023-09-15 13:15:37 +05:30
1 parent cc73c531fa
commit 28f6050a97
10 files changed
+44 -13

No files matched your search

+32
View File
@@ -0,0 +1,32 @@
/** @format */
import React from "react";
class ErrorBoundary extends React.Component {
constructor(props) {
super(props);
this.state = { hasError: false };
}
static getDerivedStateFromError(error) {
// Update state so the next render will show the fallback UI.
return { hasError: true };
}
componentDidCatch(error, info) {
// Example "componentStack":
// in ComponentThatThrows (created by App)
// in ErrorBoundary (created by App)
// in div (created by App)
// in App
logErrorToMyService(error, info.componentStack);
}
render() {
if (this.state.hasError) {
// You can render any custom fallback UI
return this.props.fallback;
}
return this.props.children;
}
}
export default ErrorBoundary;