@navinc/base-react-components
Version:
Nav's Pattern Library
19 lines • 794 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.WaitForDependencies = void 0;
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;
};
exports.WaitForDependencies = WaitForDependencies;
//# sourceMappingURL=wait-for-dependencies.js.map