18 lines
437 B
JavaScript
18 lines
437 B
JavaScript
import React from "react";
|
|
import { useDispatch, useSelector } from "react-redux";
|
|
import { Redirect } from "react-router-dom";
|
|
|
|
import { userLogout } from "../../actions/users";
|
|
|
|
export const UserLogout = () => {
|
|
const dispatch = useDispatch();
|
|
const isLogged = useSelector((state) => state.user.isLogged);
|
|
|
|
if (isLogged) {
|
|
dispatch(userLogout());
|
|
return null;
|
|
} else {
|
|
return <Redirect to="/users/login" />;
|
|
}
|
|
};
|