tiagobento commented on code in PR #3031:
URL: 
https://github.com/apache/incubator-kie-tools/pull/3031#discussion_r2037801627


##########
packages/dmn-editor/src/dataTypes/DataTypes.tsx:
##########
@@ -169,13 +182,37 @@ export function DataTypes() {
         addTopLevelItemDefinition(itemDefinition);
       }
     });
-  }, [addTopLevelItemDefinition, settings.isReadOnly]);
+  }, [addTopLevelItemDefinition, isReadOnly]);
 
   const [isAddDataTypeDropdownOpen, setAddDataTypeDropdownOpen] = 
useState(false);
 
   // Using this object because DropdownToggleAction's props doesn't accept a 
'title'.
   const extraPropsForDropdownToggleAction = { title: "New Data Type" };
 
+  const addDataTypesDropdownItems = useMemo(() => {
+    const dropdownItems = [
+      <DropdownItem
+        key={"paste"}
+        onClick={() => pasteTopLevelItemDefinition()}
+        style={{ minWidth: "240px" }}
+        icon={<PasteIcon />}
+      >
+        Paste
+      </DropdownItem>,
+    ];
+    if (isImportDataTypesFromJavaClassesSupported && 
javaCodeCompletionService) {
+      dropdownItems.unshift(
+        <ImportJavaClassesI18nDictionariesProvider key={"import-java-classes"}>
+          <ImportJavaClassesDropdownItem
+            javaCodeCompletionService={javaCodeCompletionService}
+            onClick={handleImportJavaClassButtonClick}
+          />
+        </ImportJavaClassesI18nDictionariesProvider>
+      );
+    }
+    return dropdownItems;
+  }, [isImportDataTypesFromJavaClassesSupported, javaCodeCompletionService]);

Review Comment:
   Adding dependencies pointed by ESLint helps us make sure our React apps are 
adhering to good reactivity practices. It's a defensive practice we do to not 
lose control when things change.
   
   Although some people recommend not memoizing by default (I.e., useMemos and 
useCallbacks), or carefully crafting the list of dependencies for each hook, we 
found out that standardizing the use of memoization hooks combined with the 
exhaustive list of dependencies of that hook helped us keep the codebase 
resilient to changes.
   
   That's more a convention on our side than anything else, really 😊 



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