refactor: useSelector

This commit is contained in:
Tristan Yang
2023-08-29 11:33:23 +08:00
parent 647bae7116
commit fe10a1c374
116 changed files with 572 additions and 661 deletions
+3 -1
View File
@@ -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();