import React, {useContext, useEffect} from 'react'; import {AuthContext} from "../App"; import {logout} from "../auth"; import {Link} from "react-router-dom"; import {toast} from "react-toastify"; function Logout(props) { const {authDispatch, authState} = useContext(AuthContext) useEffect(() => { if (authState.loggedIn) authDispatch({response: logout(authState.token)}) else toast.warn("You are not logged in!") props.history.push("/") }) return (
You will soon be redirected. Click here if you are not.
); } export default Logout;