This repository has been archived on 2025-07-07. You can view files and clone it, but cannot push or open issues or pull requests.
Files
2025-01-11 09:54:09 +03:00

15 lines
526 B
JavaScript

import * as React from 'react';
import { useSidecar } from './hook';
// eslint-disable-next-line @typescript-eslint/ban-types
export function sidecar(importer, errorComponent) {
const ErrorCase = () => errorComponent;
return function Sidecar(props) {
const [Car, error] = useSidecar(importer, props.sideCar);
if (error && errorComponent) {
return ErrorCase;
}
// @ts-expect-error type shenanigans
return Car ? React.createElement(Car, { ...props }) : null;
};
}