daddy/client/src/components/WithLoader.tsx

18 lines
448 B
TypeScript
Raw Normal View History

2020-07-21 22:25:39 +02:00
import React, { Fragment, PropsWithChildren, FunctionComponent } from 'react';
export interface WithLoaderProps {
loading?: boolean|boolean[]
2020-07-21 22:25:39 +02:00
}
export const WithLoader: FunctionComponent<WithLoaderProps> = ({ loading, children }) => {
const isLoading = Array.isArray(loading) ? loading.some(l => l) : loading;
2020-07-21 22:25:39 +02:00
return (
<Fragment>
{
isLoading ?
2020-07-22 09:18:50 +02:00
<div>Chargement</div> :
2020-07-21 22:25:39 +02:00
children
}
</Fragment>
)
}