import React from "react";
class RicosErrorBoundary extends React.Component {
  constructor() {
    super(...arguments);
    this.state = { error: "" };
  }
  static getDerivedStateFromError(error) {
    return { error };
  }
  componentDidCatch(error, errorInfo) {
    if (this.props.editor) {
      this.props.editor.publishError(error, errorInfo);
    } else {
      console.error("Error inside Ricos", error, errorInfo);
    }
  }
  render() {
    try {
      if (this.state.error) {
        this.props.onError?.(this.state.error);
        return null;
      }
      return this.props.children;
    } catch (e) {
      this.props.onError?.(e);
      return null;
    }
  }
}
export {
  RicosErrorBoundary
};
//# sourceMappingURL=ricos-error-boundary.js.map
