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


##########
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:
   Thank you @thiagoelg , I have locally tried your proposal and it works. 
Changes are pushed now as 
https://github.com/apache/incubator-kie-tools/pull/4069/commits/79f8f825ea2364809063a9f6c8930481ea139784



-- 
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