UNPKG

streamlit-component-lib-react-hooks

Version:

An npm package that provides support code for creating [Streamlit Components](https://docs.streamlit.io/en/stable/streamlit_components.html) with React and React Hooks.

23 lines (22 loc) 727 B
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime"; import React from "react"; /** * Shows errors thrown from child components. */ class ErrorBoundary extends React.PureComponent { constructor(props) { super(props); this.state = { error: undefined }; } static getDerivedStateFromError(error) { // Update state so the next render will show the fallback UI. return { error }; } render() { if (this.state.error != null) { return (_jsxs("div", { children: [_jsx("h1", { children: "Component Error" }), _jsx("span", { children: this.state.error.message })] })); } return this.props.children; } } export default ErrorBoundary;