UNPKG

@storybook/addon-ondevice-notes

Version:

Write notes for your react-native Storybook stories.

32 lines (31 loc) 1.16 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.ErrorBoundary = void 0; const jsx_runtime_1 = require("react/jsx-runtime"); const react_1 = __importDefault(require("react")); const react_native_1 = require("react-native"); class ErrorBoundary extends react_1.default.Component { constructor(props) { super(props); this.state = { hasError: false }; } static getDerivedStateFromError(_error) { // Update state so the next render will show the fallback UI. return { hasError: true }; } componentDidCatch(error, errorInfo) { // You can also log the error to an error reporting service console.warn(error, errorInfo); } render() { if (this.state.hasError) { // You can render any custom fallback UI return (0, jsx_runtime_1.jsx)(react_native_1.Text, { children: "Something went wrong." }); } return this.props.children; } } exports.ErrorBoundary = ErrorBoundary;