Просмотр исходного кода

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 недель назад
Родитель
Сommit
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({