18 lines
448 B
TypeScript
18 lines
448 B
TypeScript
|
import React, { Fragment, PropsWithChildren, FunctionComponent } from 'react';
|
||
|
|
||
|
export interface WithLoaderProps {
|
||
|
loading?: boolean|boolean[]
|
||
|
}
|
||
|
|
||
|
export const WithLoader: FunctionComponent<WithLoaderProps> = ({ loading, children }) => {
|
||
|
const isLoading = Array.isArray(loading) ? loading.some(l => l) : loading;
|
||
|
return (
|
||
|
<Fragment>
|
||
|
{
|
||
|
isLoading ?
|
||
|
<div>Chargement</div> :
|
||
|
children
|
||
|
}
|
||
|
</Fragment>
|
||
|
)
|
||
|
}
|