import React from 'react'; export default class ErrorHandler extends React.Component { constructor(props) { super(props); this.state = { hasError: false }; } componentDidCatch(error, info) { this.setState({ hasError: true }); } render() { if (this.state.hasError) { // You can render any custom fallback UI return (