d4652b3dd8
* enable strict mode and fix resulting type errors * fix print affected command * remove assign-deep and use lodash/merge, fix some type errors after enabling strict mode
28 lines
567 B
TypeScript
28 lines
567 B
TypeScript
import { Splash } from '@vegaprotocol/ui-toolkit';
|
|
import { ReactNode } from 'react';
|
|
|
|
interface AsyncRendererProps<T> {
|
|
loading: boolean;
|
|
error: Error | undefined | null;
|
|
data: T | undefined;
|
|
children: (data: T) => ReactNode;
|
|
}
|
|
|
|
// eslint-disable-next-line
|
|
export function AsyncRenderer<T = any>({
|
|
loading,
|
|
error,
|
|
data,
|
|
children,
|
|
}: AsyncRendererProps<T>) {
|
|
if (error) {
|
|
return <Splash>Something went wrong: {error.message}</Splash>;
|
|
}
|
|
|
|
if (loading || !data) {
|
|
return <Splash>Loading...</Splash>;
|
|
}
|
|
|
|
return <>{children(data)}</>;
|
|
}
|