@remotion/player
Version:
React component for embedding a Remotion preview into your app
40 lines (39 loc) • 1.26 kB
JavaScript
;
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 errorStyle = {
display: 'flex',
justifyContent: 'center',
alignItems: 'center',
flex: 1,
height: '100%',
width: '100%',
};
class ErrorBoundary extends react_1.default.Component {
constructor() {
super(...arguments);
this.state = { hasError: null };
}
static getDerivedStateFromError(error) {
// Update state so the next render will show the fallback UI.
return { hasError: error };
}
componentDidCatch(error) {
this.props.onError(error);
}
render() {
if (this.state.hasError) {
// You can render any custom fallback UI
return ((0, jsx_runtime_1.jsx)("div", { style: errorStyle, children: this.props.errorFallback({
error: this.state.hasError,
}) }));
}
return this.props.children;
}
}
exports.ErrorBoundary = ErrorBoundary;