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.
28 lines (27 loc) • 1.02 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const jsx_runtime_1 = require("react/jsx-runtime");
const react_1 = __importDefault(require("react"));
/**
* Shows errors thrown from child components.
*/
class ErrorBoundary extends react_1.default.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 ((0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsx)("h1", { children: "Component Error" }), (0, jsx_runtime_1.jsx)("span", { children: this.state.error.message })] }));
}
return this.props.children;
}
}
exports.default = ErrorBoundary;