UNPKG

@vectara/vectara-ui

Version:

Vectara's design system, codified as a React and Sass component library

25 lines (24 loc) 800 B
import * as React from "react"; export class VuiErrorBoundary extends React.Component { constructor(props) { super(props); this.state = { error: undefined }; } static getDerivedStateFromError(error) { // Update state so the next render will show the fallback UI. return { error }; } componentDidCatch(error, info) { var _a, _b; console.log("caught error:", error, info); (_b = (_a = this.props).onError) === null || _b === void 0 ? void 0 : _b.call(_a, error, info); } render() { if (this.state.error) { // You can render any custom fallback UI return this.props.fallback; } // Access the children prop, which is now typed. return this.props.children; } }