@navinc/base-react-components
Version:
Nav's Pattern Library
15 lines • 635 B
JavaScript
export const WaitForDependencies = ({ children, ErrorContent, LoadingContent, loadingProps = [], hasDependencyProps = [], }) => {
const hasAllDataDependencies = hasDependencyProps.reduce((accumulator, current) => current && accumulator, true);
const areAnyLoading = loadingProps.reduce((accumulator, current) => current || accumulator, false);
if (hasAllDataDependencies) {
return children;
}
else if (areAnyLoading && LoadingContent) {
return LoadingContent;
}
else if (ErrorContent) {
return ErrorContent;
}
return null;
};
//# sourceMappingURL=wait-for-dependencies.js.map