Explorar o código

fix: infinite useEffect

Soham Parekh %!s(int64=3) %!d(string=hai) anos
pai
achega
2729d173ee

+ 5 - 5
dashboard/src/main/home/cluster-dashboard/preview-environments/deployments/DeploymentDetail.tsx

@@ -23,8 +23,8 @@ const DeploymentDetail = () => {
   const [environmentId, setEnvironmentId] = useState("");
   const [showRepoTooltip, setShowRepoTooltip] = useState(false);
   const [porterYAMLErrors, setPorterYAMLErrors] = useState<string[]>([]);
-  const [expandedPorterYAMLErrors, setExpandedPorterYAMLErrors] = useState(
-    null
+  const [expandedPorterYAMLErrors, setExpandedPorterYAMLErrors] = useState<string[]>(
+    []
   );
 
   const { currentProject, currentCluster } = useContext(Context);
@@ -96,15 +96,15 @@ const DeploymentDetail = () => {
           setPorterYAMLErrors([]);
         }
       });
-  });
+  }, []);
 
   let repository = `${prDeployment.gh_repo_owner}/${prDeployment.gh_repo_name}`;
 
   return (
     <>
-      {expandedPorterYAMLErrors && (
+      {expandedPorterYAMLErrors.length && (
         <Modal
-          onRequestClose={() => setExpandedPorterYAMLErrors(null)}
+          onRequestClose={() => setExpandedPorterYAMLErrors([])}
           height="auto"
         >
           <Message>

+ 1 - 1
dashboard/src/shared/api.tsx

@@ -271,7 +271,7 @@ const validatePorterYAML = baseApi<
     environment_id: number;
   }
 >("GET", (pathParams) => {
-  let { project_id, cluster_id, environment_id } = pathParams;
+  const { project_id, cluster_id, environment_id } = pathParams;
   return `/api/projects/${project_id}/clusters/${cluster_id}/environments/${environment_id}/validate_porter_yaml`;
 });