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>
  )
}