From 236062c6c6278c4b433463fef9fa37eebf3fd760 Mon Sep 17 00:00:00 2001 From: eug-vs Date: Sun, 9 Aug 2020 16:09:21 +0300 Subject: feat: lazy-load pages --- src/pages/Page.tsx | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) (limited to 'src/pages/Page.tsx') diff --git a/src/pages/Page.tsx b/src/pages/Page.tsx index 668b171..49c941a 100644 --- a/src/pages/Page.tsx +++ b/src/pages/Page.tsx @@ -1,15 +1,16 @@ -import React from 'react'; +import React, { Suspense } from 'react'; import { makeStyles, useTheme } from '@material-ui/core/styles'; import { useMediaQuery } from '@material-ui/core'; import { SnackbarProvider } from 'notistack'; import { Switch, Route } from 'react-router-dom'; +import Loading from '../components/Loading/Loading'; -import ProfilePage from './ProfilePage/ProfilePage'; -import FeedPage from './FeedPage/FeedPage'; -import LoginPage from './LoginPage/LoginPage'; -import RegistrationPage from './RegistrationPage/RegistrationPage'; -import HomePage from './HomePage/HomePage'; -import NotificationsPage from './NotificationsPage/NotificationsPage'; +const ProfilePage = React.lazy(() => import( './ProfilePage/ProfilePage')); +const FeedPage = React.lazy(() => import( './FeedPage/FeedPage')); +const LoginPage = React.lazy(() => import( './LoginPage/LoginPage')); +const RegistrationPage = React.lazy(() => import( './RegistrationPage/RegistrationPage')); +const HomePage = React.lazy(() => import( './HomePage/HomePage')); +const NotificationsPage = React.lazy(() => import( './NotificationsPage/NotificationsPage')); const useStyles = makeStyles(theme => ({ @@ -38,14 +39,16 @@ const Page: React.FC = () => { }} >
- - - - - - - - + }> + + + + + + + + +
); -- cgit v1.2.3 From fd6e663a1bcc43cfc49bda99ccbfab380489324b Mon Sep 17 00:00:00 2001 From: eug-vs Date: Mon, 10 Aug 2020 00:02:24 +0300 Subject: feat!: add useLocalStorage hook --- src/pages/Page.tsx | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/pages/Page.tsx') diff --git a/src/pages/Page.tsx b/src/pages/Page.tsx index 49c941a..a77a98e 100644 --- a/src/pages/Page.tsx +++ b/src/pages/Page.tsx @@ -5,12 +5,12 @@ import { SnackbarProvider } from 'notistack'; import { Switch, Route } from 'react-router-dom'; import Loading from '../components/Loading/Loading'; -const ProfilePage = React.lazy(() => import( './ProfilePage/ProfilePage')); -const FeedPage = React.lazy(() => import( './FeedPage/FeedPage')); -const LoginPage = React.lazy(() => import( './LoginPage/LoginPage')); -const RegistrationPage = React.lazy(() => import( './RegistrationPage/RegistrationPage')); -const HomePage = React.lazy(() => import( './HomePage/HomePage')); -const NotificationsPage = React.lazy(() => import( './NotificationsPage/NotificationsPage')); +const ProfilePage = React.lazy(() => import('./ProfilePage/ProfilePage')); +const FeedPage = React.lazy(() => import('./FeedPage/FeedPage')); +const LoginPage = React.lazy(() => import('./LoginPage/LoginPage')); +const RegistrationPage = React.lazy(() => import('./RegistrationPage/RegistrationPage')); +const HomePage = React.lazy(() => import('./HomePage/HomePage')); +const NotificationsPage = React.lazy(() => import('./NotificationsPage/NotificationsPage')); const useStyles = makeStyles(theme => ({ -- cgit v1.2.3 From 7ba15a22d1bd57e7c26ff2d5fccf5505aaf8619e Mon Sep 17 00:00:00 2001 From: eug-vs Date: Mon, 10 Aug 2020 00:28:39 +0300 Subject: refactor: move pages -> containers --- src/pages/Page.tsx | 59 ------------------------------------------------------ 1 file changed, 59 deletions(-) delete mode 100644 src/pages/Page.tsx (limited to 'src/pages/Page.tsx') diff --git a/src/pages/Page.tsx b/src/pages/Page.tsx deleted file mode 100644 index a77a98e..0000000 --- a/src/pages/Page.tsx +++ /dev/null @@ -1,59 +0,0 @@ -import React, { Suspense } from 'react'; -import { makeStyles, useTheme } from '@material-ui/core/styles'; -import { useMediaQuery } from '@material-ui/core'; -import { SnackbarProvider } from 'notistack'; -import { Switch, Route } from 'react-router-dom'; -import Loading from '../components/Loading/Loading'; - -const ProfilePage = React.lazy(() => import('./ProfilePage/ProfilePage')); -const FeedPage = React.lazy(() => import('./FeedPage/FeedPage')); -const LoginPage = React.lazy(() => import('./LoginPage/LoginPage')); -const RegistrationPage = React.lazy(() => import('./RegistrationPage/RegistrationPage')); -const HomePage = React.lazy(() => import('./HomePage/HomePage')); -const NotificationsPage = React.lazy(() => import('./NotificationsPage/NotificationsPage')); - - -const useStyles = makeStyles(theme => ({ - root: { - [theme.breakpoints.down('sm')]: { - margin: theme.spacing(2, 0, 12, 0) - }, - [theme.breakpoints.up('md')]: { - margin: theme.spacing(15, 5, 8, 5) - } - } -})); - - -const Page: React.FC = () => { - const classes = useStyles(); - const theme = useTheme(); - const isMobile = useMediaQuery(theme.breakpoints.down('sm')); - - return ( - -
- }> - - - - - - - - - -
-
- ); -}; - - -export default Page; - -- cgit v1.2.3