Spaces:
Sleeping
Sleeping
File size: 642 Bytes
471f166 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
import React from 'react'
class ErrorBoundary extends React.Component {
constructor(props) {
super(props)
this.state = { hasError: false }
}
static getDerivedStateFromError(error) {
return { hasError: true }
}
componentDidCatch(error, errorInfo) {
console.error("Markdown rendering error:", error, errorInfo)
}
render() {
if (this.state.hasError) {
return this.props.fallback || <span className="text-red-500 text-sm">⚠️ Không thể hiển thị nội dung này</span>
}
return this.props.children
}
}
export default ErrorBoundary
|