Skip to content

Commit

Permalink
fix(menu): ignore exhaustive deps
Browse files Browse the repository at this point in the history
  • Loading branch information
Coread committed Oct 1, 2024
1 parent bf44346 commit b89da7c
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 8 deletions.
3 changes: 2 additions & 1 deletion src/components/Menu/Menu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,8 @@ const Menu = <T extends object>(props: Props<T>, providedRef: RefObject<HTMLDivE
return menuItem;
}
},
[_props.onAction]
// eslint-disable-next-line react-hooks/exhaustive-deps
[state]
);

// needs to be removed because when used in Menu Trigger, it will
Expand Down
3 changes: 2 additions & 1 deletion src/components/MenuSection/MenuSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ const MenuSection = <T extends object>(props: Props<T>): ReactElement => {
}
return <MenuItem key={node.key} item={node} state={state} onAction={onAction} />;
});
}, [item.childNodes, onAction, state]);
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [state]);

return (
<div {...itemProps}>
Expand Down
6 changes: 4 additions & 2 deletions src/components/MenuSelectionGroup/MenuSelectionGroup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,14 @@ const MenuSelectionGroup = <T extends object>(props: Props<T>): ReactElement =>

useEffect(() => {
menuSelectionManager.setFocusedKey(selectionManager.focusedKey);
}, [menuSelectionManager, selectionManager.focusedKey]);
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [selectionManager.focusedKey]);

useEffect(() => {
selectionManager.setFocused(menuSelectionManager.isFocused);
selectionManager.setFocusedKey(menuSelectionManager.focusedKey);
}, [menuSelectionManager.focusedKey, menuSelectionManager.isFocused, selectionManager]);
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [menuSelectionManager.focusedKey, menuSelectionManager.isFocused]);

const { itemProps, headingProps, groupProps } = useMenuSection({
heading: item.rendered,
Expand Down
6 changes: 4 additions & 2 deletions src/components/Tree/Tree.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,8 @@ const Tree = forwardRef((props: Props, ref: ForwardedRef<TreeRefObject>) => {
onToggleNode?.(id, newOpenState);
setTree((prevTree) => toggleTreeNodeRecord(id, prevTree, newOpenState));
},
[tree, isVirtualTree, onToggleNode, activeNodeId, virtualTreeConnector]
// eslint-disable-next-line react-hooks/exhaustive-deps
[tree, isVirtualTree]
);

const getNodeDetails = useCallback((id: TreeNodeId) => tree.get(id), [tree]);
Expand Down Expand Up @@ -143,7 +144,8 @@ const Tree = forwardRef((props: Props, ref: ForwardedRef<TreeRefObject>) => {
groupProps,
};
},
[excludeTreeRoot, tree]
// eslint-disable-next-line react-hooks/exhaustive-deps
[tree]
);

const context = useMemo(
Expand Down
5 changes: 3 additions & 2 deletions src/hooks/useItemSelected.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,8 @@ export const useItemSelected = <TItemId extends string | number>({
isControlled
? new Set(getSelection(selectionMode, selectedItemsFromProps))
: internalSelectedItems,
[isControlled, selectionMode, selectedItemsFromProps, internalSelectedItems]
// eslint-disable-next-line react-hooks/exhaustive-deps
[isControlled, selectedItemsFromProps, internalSelectedItems]
);

return useMemo(
Expand Down Expand Up @@ -227,6 +228,6 @@ export const useItemSelected = <TItemId extends string | number>({
},
}),
// eslint-disable-next-line react-hooks/exhaustive-deps
[isControlled, isRequired, onSelectionChange, selectedItems, selectionMode]
[selectedItems]
);
};

0 comments on commit b89da7c

Please sign in to comment.