refactor: useSelector
This commit is contained in:
@@ -4,12 +4,14 @@ import { Navigate } from "react-router-dom";
|
||||
import { useLazyGuestLoginQuery } from "../app/services/auth";
|
||||
import { useAppSelector } from "../app/store";
|
||||
import { useEffect } from "react";
|
||||
import { shallowEqual } from "react-redux";
|
||||
|
||||
// type Props = {};
|
||||
|
||||
const GuestLogin = () => {
|
||||
const [guestLogin] = useLazyGuestLoginQuery();
|
||||
const { token, guest } = useAppSelector((store) => store.authData);
|
||||
const token = useAppSelector((store) => store.authData.token, shallowEqual);
|
||||
const guest = useAppSelector((store) => store.authData.guest, shallowEqual);
|
||||
useEffect(() => {
|
||||
if (!guest || !token) {
|
||||
guestLogin();
|
||||
|
||||
Reference in New Issue
Block a user