itizawa 5 ani în urmă
părinte
comite
5a3ee6db76

+ 2 - 3
src/client/js/components/PageHistory.jsx

@@ -5,7 +5,7 @@ import loggerFactory from '@alias/logger';
 import { withUnstatedContainers } from './UnstatedUtils';
 import { withUnstatedContainers } from './UnstatedUtils';
 import { toastError } from '../util/apiNotification';
 import { toastError } from '../util/apiNotification';
 
 
-import withSuspense from './withSuspense';
+import { withLoadingSppiner } from './SuspenseUtils';
 import PageRevisionList from './PageHistory/PageRevisionList';
 import PageRevisionList from './PageHistory/PageRevisionList';
 
 
 import PageHistroyContainer from '../services/PageHistoryContainer';
 import PageHistroyContainer from '../services/PageHistoryContainer';
@@ -52,8 +52,7 @@ function PageHistory(props) {
 
 
 }
 }
 
 
-const RenderPageHistoryWithSuspense = withSuspense(PageHistory);
-const RenderPageHistoryWrapper = withUnstatedContainers(RenderPageHistoryWithSuspense, [PageHistroyContainer]);
+const RenderPageHistoryWrapper = withUnstatedContainers(withLoadingSppiner(PageHistory), [PageHistroyContainer]);
 
 
 PageHistory.propTypes = {
 PageHistory.propTypes = {
   pageHistoryContainer: PropTypes.instanceOf(PageHistroyContainer).isRequired,
   pageHistoryContainer: PropTypes.instanceOf(PageHistroyContainer).isRequired,

+ 6 - 3
src/client/js/components/withSuspense.jsx → src/client/js/components/SuspenseUtils.jsx

@@ -1,6 +1,11 @@
+/* eslint-disable import/prefer-default-export */
 import React, { Suspense } from 'react';
 import React, { Suspense } from 'react';
 
 
-function withSuspense(Component) {
+/**
+ * If you throw a Promise in the component, it will display a sppiner
+ * @param {object} Component A React.Component or functional component
+ */
+export function withLoadingSppiner(Component) {
   return (props => (
   return (props => (
     // wrap with <Suspense></Suspense>
     // wrap with <Suspense></Suspense>
     <Suspense
     <Suspense
@@ -14,5 +19,3 @@ function withSuspense(Component) {
     </Suspense>
     </Suspense>
   ));
   ));
 }
 }
-
-export default withSuspense;