Replaced react-loadable with @loadable/component

This commit is contained in:
2021-03-24 01:03:11 +11:00
parent 9788552d0c
commit 4280319443
4 changed files with 38 additions and 50 deletions
+5 -31
View File
@@ -1,39 +1,13 @@
import React from 'react';
import { Route } from 'react-router-dom';
import Loadable from 'react-loadable';
import loadable from '@loadable/component';
const Loading = props => {
if (props.error) {
return <p>{props.error}</p>;
}
const LazyRoute = props => {
const { component, ...lazyProps } = props;
if (props.timedOut) {
return (
<div className='page'>
<p>Page Timed Out</p>
</div>
);
}
const lazyComponent = loadable(component);
if (props.pastDelay) {
return (
<div className='page'>
<p>Page Loading...</p>
</div>
);
}
return null;
};
const LazyRoute = lazyProps => {
const component = Loadable({
loader: lazyProps.component,
loading: Loading,
timeout: 10000
});
return <Route {...lazyProps} component={component} />
return <Route {...lazyProps} component={lazyComponent} />
};
export default LazyRoute;