stream-chat-react
Version:
React components to create chat conversations or livestream style chat
20 lines (19 loc) • 495 B
JavaScript
import { Component } from 'react';
export class ErrorBoundary extends Component {
constructor(props) {
super(props);
this.state = { hasError: false };
}
static getDerivedStateFromError() {
return { hasError: true };
}
componentDidCatch(error, information) {
console.error(error, information);
}
render() {
if (this.state.hasError) {
return this.props.fallback;
}
return this.props.children;
}
}