aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoreug-vs <eug-vs@keemail.me>2020-08-08 09:49:38 +0300
committereug-vs <eug-vs@keemail.me>2020-08-08 09:49:38 +0300
commitb446a83ff24ed5ea2233c544446557ee29f44364 (patch)
tree54cf4a3a85c2a2bb7215c0ae10b6ced050242102
parent6a0b6ec911c39989a1af4322e2a32d75fddbb274 (diff)
downloadwhich-ui-b446a83ff24ed5ea2233c544446557ee29f44364.tar.gz
refactor: use native Route component
-rw-r--r--src/components/Header/Header.tsx2
-rw-r--r--src/pages/Page.tsx3
-rw-r--r--src/pages/ProfilePage/ProfilePage.tsx7
-rw-r--r--src/pages/Route.tsx11
4 files changed, 5 insertions, 18 deletions
diff --git a/src/components/Header/Header.tsx b/src/components/Header/Header.tsx
index 9c42c31..5aa66ba 100644
--- a/src/components/Header/Header.tsx
+++ b/src/components/Header/Header.tsx
@@ -54,7 +54,7 @@ const Header: React.FC = () => {
};
const handleFeed = (): void => {
- history.push('/feed')
+ history.push('/feed');
};
const handleProfile = (): void => {
diff --git a/src/pages/Page.tsx b/src/pages/Page.tsx
index 34a1046..668b171 100644
--- a/src/pages/Page.tsx
+++ b/src/pages/Page.tsx
@@ -2,7 +2,7 @@ import React from 'react';
import { makeStyles, useTheme } from '@material-ui/core/styles';
import { useMediaQuery } from '@material-ui/core';
import { SnackbarProvider } from 'notistack';
-import { Switch } from 'react-router-dom';
+import { Switch, Route } from 'react-router-dom';
import ProfilePage from './ProfilePage/ProfilePage';
import FeedPage from './FeedPage/FeedPage';
@@ -10,7 +10,6 @@ import LoginPage from './LoginPage/LoginPage';
import RegistrationPage from './RegistrationPage/RegistrationPage';
import HomePage from './HomePage/HomePage';
import NotificationsPage from './NotificationsPage/NotificationsPage';
-import Route from './Route';
const useStyles = makeStyles(theme => ({
diff --git a/src/pages/ProfilePage/ProfilePage.tsx b/src/pages/ProfilePage/ProfilePage.tsx
index b81c70f..ae94b9f 100644
--- a/src/pages/ProfilePage/ProfilePage.tsx
+++ b/src/pages/ProfilePage/ProfilePage.tsx
@@ -29,12 +29,11 @@ const ProfilePage: React.FC = () => {
if (username) {
get(`/users?username=${username}`).then(response => {
- if (!response.data.length) return redirect(); // TODO: handle this case
+ if (!response.data.length) redirect(); // TODO: handle this case
setUserInfo(response.data[0]);
setIsInfoLoading(false);
}).catch(() => redirect());
- } else redirect()
-
+ } else redirect();
}, [username, user, history]);
@@ -54,7 +53,7 @@ const ProfilePage: React.FC = () => {
));
});
}
- }, [userInfo])
+ }, [userInfo]);
return (
<Container maxWidth="sm" disableGutters>
diff --git a/src/pages/Route.tsx b/src/pages/Route.tsx
deleted file mode 100644
index fdd6f96..0000000
--- a/src/pages/Route.tsx
+++ /dev/null
@@ -1,11 +0,0 @@
-import React from 'react';
-import { Route as BaseRoute } from 'react-router-dom';
-
-
-const Route: React.FC<any> = ({ component: Component, ...rest }) => {
- const render: React.FC<any> = (props) => <Component {...props} />;
-
- return <BaseRoute render={render} {...rest} />;
-};
-
-export default Route;