Files
zkldi_Tachi/client/src/components/util/LoadingWrapper.tsx
T
2021-11-17 17:26:53 +00:00

28 lines
589 B
TypeScript

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