Browse Source

加购弹窗隐藏后销毁

fogwind 3 days ago
parent
commit
49233bc8ee
1 changed files with 8 additions and 1 deletions
  1. 8 1
      src/components/common/AddToCartModal/AddToCartModalWrapper.tsx

+ 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";