|
@@ -6,7 +6,7 @@ import { brandList } from "@/utils/constant";
|
|
|
import { Button, Modal, ModalBody, ModalContent, useDisclosure } from "@nextui-org/react";
|
|
|
import { Toast } from "antd-mobile";
|
|
|
import { useTranslations } from "next-intl";
|
|
|
-import { FC, PropsWithChildren, ReactNode, useRef } from "react";
|
|
|
+import { FC, PropsWithChildren, ReactNode, useEffect, useRef } from "react";
|
|
|
import styles from "./style.module.scss";
|
|
|
export interface CardProps {
|
|
|
item?: GameListRep;
|
|
@@ -15,7 +15,8 @@ export interface CardProps {
|
|
|
const Card: FC<PropsWithChildren<CardProps>> = (props) => {
|
|
|
const { render, item } = props;
|
|
|
const { isOpen, onOpen, onOpenChange, onClose } = useDisclosure();
|
|
|
- const app: HTMLElement = document.querySelector("#app")!;
|
|
|
+ const appRef = useRef<Element>();
|
|
|
+
|
|
|
const t = useTranslations("Game");
|
|
|
const urlRef = useRef<string>("");
|
|
|
const brandRef = useRef<string>("");
|
|
@@ -23,6 +24,9 @@ const Card: FC<PropsWithChildren<CardProps>> = (props) => {
|
|
|
const state = useGlobalStore();
|
|
|
const router = useRouter();
|
|
|
const { token } = state;
|
|
|
+ useEffect(() => {
|
|
|
+ appRef.current = document.querySelector("#app")!;
|
|
|
+ }, []);
|
|
|
const handler = (game: GameListRep) => {
|
|
|
onOpen();
|
|
|
brandRef.current = brandList.find((item) => item.gid === game.game_id)?.brand ?? "";
|
|
@@ -58,7 +62,7 @@ const Card: FC<PropsWithChildren<CardProps>> = (props) => {
|
|
|
)}
|
|
|
<Modal
|
|
|
isOpen={isOpen}
|
|
|
- portalContainer={app}
|
|
|
+ portalContainer={appRef.current}
|
|
|
placement={"bottom"}
|
|
|
onOpenChange={onOpenChange}
|
|
|
classNames={{
|