Files
zkldi_Tachi/client/src/components/util/LoadingWrapper.tsx
T
2022-08-27 15:30:33 +01:00

26 lines
544 B
TypeScript

import Loading from "components/util/Loading";
import React, { CSSProperties } from "react";
import { UnsuccessfulAPIResponse } from "tachi-common";
export default function LoadingWrapper({
dataset,
error,
children,
style,
}: {
dataset: unknown | null | undefined;
error: UnsuccessfulAPIResponse | null;
children: JSX.Element | JSX.Element[];
style?: CSSProperties;
}) {
if (error) {
return <h3>An error has occurred. {error.description}</h3>;
}
if (!dataset) {
return <Loading style={style} />;
}
return <>{children}</>;
}