# All files / components/Loading index.js

100% Statements 8/8
100% Branches 8/8
100% Functions 1/1
100% Lines 8/8

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26

    2x
    3x
    1x
    2x
    1x

    1x

    2x

    2x

     import React from 'react';
    import PropTypes from 'prop-types';
    import Loader from '../Loader';

    const Loading = ({ isLoading, pastDelay, error }) => {
      if (isLoading && pastDelay) {
        return <Loader active type="ball-clip-rotate" size="large" />;
      } else if (error && !isLoading) {
        return <p>Error!</p>;
      }
      return null;
    };

    Loading.propTypes = {
      isLoading: PropTypes.bool,
      pastDelay: PropTypes.oneOfType([
        PropTypes.number,
        PropTypes.bool,
      ]),
      error: PropTypes.object,
    };

    Loading.displayName = 'Loading';

    export default Loading;