SuspenseUtils.jsx 587 B

123456789101112131415161718192021
  1. /* eslint-disable import/prefer-default-export */
  2. import React, { Suspense } from 'react';
  3. /**
  4. * If you throw a Promise in the component, it will display a sppiner
  5. * @param {object} Component A React.Component or functional component
  6. */
  7. export function withLoadingSppiner(Component) {
  8. return (props => (
  9. // wrap with <Suspense></Suspense>
  10. <Suspense
  11. fallback={(
  12. <div className="my-5 text-center">
  13. <i className="fa fa-lg fa-spinner fa-pulse mx-auto text-muted"></i>
  14. </div>
  15. )}
  16. >
  17. <Component {...props} />
  18. </Suspense>
  19. ));
  20. }