From da5620519f16248af8d2d5828a88ef0a72617ec8 Mon Sep 17 00:00:00 2001 From: Dm1tr1y147 Date: Wed, 23 Sep 2020 21:05:56 +0500 Subject: [PATCH] Added redirect on visiting RemoveList component while not being logged in --- src/views/Admin/RemoveList/index.tsx | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/views/Admin/RemoveList/index.tsx b/src/views/Admin/RemoveList/index.tsx index fa79187..de5e5b9 100644 --- a/src/views/Admin/RemoveList/index.tsx +++ b/src/views/Admin/RemoveList/index.tsx @@ -1,4 +1,5 @@ import React, { Dispatch, SetStateAction, useEffect, useState } from 'react'; +import { useHistory } from 'react-router-dom'; import { IData, ILoadingState } from '../../../types'; import { fetchCardList } from '../../../utils'; @@ -16,6 +17,14 @@ const RemoveList: React.FC = ({ setLoading, token, setToken }) => { const [data, setData] = useState([]); useEffect(() => fetchCardList(setData), []); + const { push: historyPush } = useHistory(); + + useEffect(() => { + if (!token) { + historyPush('/a/l'); + } + }, [setLoading, historyPush, token]); + return (
{data.map((el, index) => (