浏览代码

Refactor mutation hook in ProductDetailView

Replaces the getAreaMutation hook with getProductMutation and triggers the mutation on component mount using useEffect. This change ensures product data is loaded when the ProductDetailView component is rendered.
hieubt 3 周之前
父节点
当前提交
1867dc780f
共有 1 个文件被更改,包括 5 次插入1 次删除
  1. 5 1
      EsimLao/esim-vite/src/pages/product-detail/ProductDetailView.tsx

+ 5 - 1
EsimLao/esim-vite/src/pages/product-detail/ProductDetailView.tsx

@@ -69,7 +69,11 @@ const ProductDetailView: React.FC = () => {
   //   staleTime: staleTime,
   // });
 
-  const getAreaMutation = useMutation({
+  useEffect(() => {
+    getProductMutation.mutate();
+  }, []);
+
+  const getProductMutation = useMutation({
     mutationFn: async () => {
       dispatch(startLoading({}));
       const res = await productApi.loadPackage({