thiagoelg commented on code in PR #4069:
URL: 
https://github.com/apache/incubator-kie-tools/pull/4069#discussion_r4473505960


##########
packages/runtime-tools-process-enveloped-components/src/formsList/envelope/components/FormsTable/FormsTable.tsx:
##########
@@ -79,11 +79,11 @@ const FormsTable: React.FC<FormsTableProps> = ({ 
channelApi, formsData, setForms
     [columns, formsData, setFormsData]
   );
 
+  // Applies the initial sort only when loading finishes. It must not depend 
on `formsData`,
+  // otherwise sorting (which creates a new array) would re-trigger this 
effect in an infinite loop.
   useEffect(() => {
-    if (!_.isEmpty(formsData)) {
-      onSort(2, "desc");
-    }
-  }, [formsData, isLoading, onSort]);
+    setFormsData((current) => (_.isEmpty(current) ? current : 
_.orderBy(current, ["lastModified"], ["desc"])));

Review Comment:
   I guess this works, but shouldn't this logic (ordering from inside the 
`setFormsData` call) be done in the `onSort` callback above?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to