Added redirect on visiting RemoveList component while not being logged in
This commit is contained in:
parent
19a4b8b43c
commit
da5620519f
@ -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<props> = ({ setLoading, token, setToken }) => {
|
||||
const [data, setData] = useState<IData[]>([]);
|
||||
useEffect(() => fetchCardList(setData), []);
|
||||
|
||||
const { push: historyPush } = useHistory();
|
||||
|
||||
useEffect(() => {
|
||||
if (!token) {
|
||||
historyPush('/a/l');
|
||||
}
|
||||
}, [setLoading, historyPush, token]);
|
||||
|
||||
return (
|
||||
<div id="deleteList">
|
||||
{data.map((el, index) => (
|
||||
|
Loading…
x
Reference in New Issue
Block a user