hoc.js 599 B

123456789101112131415
  1. import { __assign } from "tslib";
  2. import * as React from 'react';
  3. import { useSidecar } from './hook';
  4. // eslint-disable-next-line @typescript-eslint/ban-types
  5. export function sidecar(importer, errorComponent) {
  6. var ErrorCase = function () { return errorComponent; };
  7. return function Sidecar(props) {
  8. var _a = useSidecar(importer, props.sideCar), Car = _a[0], error = _a[1];
  9. if (error && errorComponent) {
  10. return ErrorCase;
  11. }
  12. // @ts-expect-error type shenanigans
  13. return Car ? React.createElement(Car, __assign({}, props)) : null;
  14. };
  15. }