remove unnecessary lazy loading
This commit is contained in:
parent
6c362a8827
commit
ee843357ad
9
src/client/Components/Result.jsx
Normal file
9
src/client/Components/Result.jsx
Normal file
@ -0,0 +1,9 @@
|
||||
import { Result } from 'antd';
|
||||
import React from 'react';
|
||||
|
||||
export default {
|
||||
404: () => <Result status="404" title="404" subTitle="Ой! Тут ничего нет." />,
|
||||
500: () => (
|
||||
<Result status="500" title="500" subTitle={'Ой! Что-то сломалось.'} />
|
||||
),
|
||||
};
|
||||
@ -1 +0,0 @@
|
||||
export { NotFound as default } from '.';
|
||||
@ -1 +0,0 @@
|
||||
export { ServerError as default } from '.';
|
||||
@ -1,10 +0,0 @@
|
||||
import React from 'react';
|
||||
import { Result, Button } from 'antd';
|
||||
|
||||
export const NotFound = () => (
|
||||
<Result status="404" title="404" subTitle="Ой! Тут ничего нет." />
|
||||
);
|
||||
|
||||
export const ServerError = () => (
|
||||
<Result status="500" title="500" subTitle={'Ой! Что-то сломалось.'} />
|
||||
);
|
||||
11
src/client/Components/Spinner.jsx
Normal file
11
src/client/Components/Spinner.jsx
Normal file
@ -0,0 +1,11 @@
|
||||
import React from 'react';
|
||||
import { Box, Flex } from 'client/UIKit/grid';
|
||||
import { Spin } from 'antd';
|
||||
|
||||
export default () => (
|
||||
<Box height="100%" py="10px">
|
||||
<Flex justifyContent="center" alignItems="center">
|
||||
<Spin />
|
||||
</Flex>
|
||||
</Box>
|
||||
);
|
||||
@ -1,16 +1,16 @@
|
||||
import { Spin } from 'antd';
|
||||
import { LoadingStatus } from 'client/common/loadingStatus';
|
||||
import Spinner from 'client/Components/Spinner';
|
||||
import { withStoreModal } from 'client/hocs/withStore';
|
||||
import { useStores } from 'client/hooks/useStores';
|
||||
import CalculationService from 'client/services/CalculationService';
|
||||
import { Box, Flex } from 'client/UIKit/grid';
|
||||
import initialOptionsMap from 'core/Data/initialOptionsMap';
|
||||
import staticEntitiesList from 'core/Data/staticEntitiesList';
|
||||
import React, { lazy, Suspense, useEffect, useState } from 'react';
|
||||
const Results = lazy(() => import('./Results'));
|
||||
const Sections = lazy(() => import('./Sections'));
|
||||
const ServerError = lazy(() => import('client/Components/Result/ServerError'));
|
||||
const Modal = lazy(() => import('client/Elements/Modal'));
|
||||
import React, { useEffect, useState } from 'react';
|
||||
import Result from 'client/Components/Result';
|
||||
import Modal from 'client/Elements/Modal';
|
||||
import Results from './Results';
|
||||
import Sections from './Sections';
|
||||
|
||||
const Calculation = () => {
|
||||
const [status, setStatus] = useState(LoadingStatus.loading);
|
||||
@ -45,28 +45,18 @@ const Calculation = () => {
|
||||
},
|
||||
)
|
||||
.catch(err => {
|
||||
console.log('Calculation -> err', err);
|
||||
setStatus(LoadingStatus.error);
|
||||
throw err;
|
||||
});
|
||||
}, []);
|
||||
|
||||
if (status === LoadingStatus.loading) {
|
||||
return (
|
||||
<Box height="100%" py="10px">
|
||||
<Flex justifyContent="center" alignItems="center">
|
||||
<Spin />
|
||||
</Flex>
|
||||
</Box>
|
||||
);
|
||||
return <Spinner />;
|
||||
}
|
||||
|
||||
if (status === LoadingStatus.error) {
|
||||
return (
|
||||
<Suspense>
|
||||
<ServerError />
|
||||
</Suspense>
|
||||
);
|
||||
const ServerError = Result[500];
|
||||
return <ServerError />;
|
||||
}
|
||||
|
||||
const ModalComponent = withStoreModal(Modal);
|
||||
|
||||
@ -6,6 +6,7 @@ import React, { Suspense } from 'react';
|
||||
import { Route, Switch } from 'react-router-dom';
|
||||
import styled from 'styled-components';
|
||||
import Logo from './Logo';
|
||||
import Spinner from 'client/Components/Spinner';
|
||||
|
||||
const HeaderContent = styled(Flex)`
|
||||
background: ${`linear-gradient(90deg,
|
||||
@ -58,10 +59,9 @@ const Header = () => (
|
||||
</header>
|
||||
);
|
||||
|
||||
//TODO: fallback
|
||||
const Content = () => (
|
||||
<Box style={styles.root}>
|
||||
<Suspense fallback={null}>
|
||||
<Suspense fallback={<Spinner />}>
|
||||
<Switch>
|
||||
{paths.map((path, i) => (
|
||||
<Route
|
||||
|
||||
@ -1,6 +1,10 @@
|
||||
import React from 'react';
|
||||
|
||||
const NotFound = React.lazy(() => import('client/Components/Result/NotFound'));
|
||||
const NotFound = React.lazy(() =>
|
||||
import('client/Components/Result').then(module => ({
|
||||
default: module.default[404],
|
||||
})),
|
||||
);
|
||||
const Calculation = React.lazy(() => import('client/Containers/Calculation'));
|
||||
|
||||
const paths = [
|
||||
|
||||
Reference in New Issue
Block a user