Sfoglia il codice sorgente

加购弹窗隐藏后销毁

fogwind 3 giorni fa
parent
commit
49233bc8ee

+ 8 - 1
src/components/common/AddToCartModal/AddToCartModalWrapper.tsx

@@ -1,9 +1,16 @@
 "use client";
 
 import AddToCartModal from "./AddToCartModal";
+import { useAppSelector } from "@/store/hooks";
 
 export function AddToCartModalWrapper() {
-  return <AddToCartModal />;
+  const {product} = useAppSelector((state) => state.addToCartDialog);
+  if(product) {
+      return <AddToCartModal />;
+  } else {
+    return null;
+  }
+  
 }
 
 // import { useAppSelector } from "@/store/hooks";