Skip to content

Commit

Permalink
Merge pull request #477 from kubeshop/catalinhoha/fix/react-hooks-deps
Browse files Browse the repository at this point in the history
fix: useNavSection react hooks deps
  • Loading branch information
devcatalin authored Oct 5, 2021
2 parents be1e084 + 11e5b93 commit a1f6124
Showing 1 changed file with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export function useNavSection<ItemType, ScopeType>(
return makeItemToPassedConditionMap(items, scope, true, getItemIdentifier);
}
return makeItemToPassedConditionMap(items, scope, handleIsVisible, getItemIdentifier);
}, [scope, itemHandler, items]);
}, [scope, itemHandler, items, getItemIdentifier]);

const isItemVisible = useCallback(
(item: ItemType) => {
Expand All @@ -86,7 +86,7 @@ export function useNavSection<ItemType, ScopeType>(
}
return Boolean(itemVisibilityMap[itemId]);
},
[itemVisibilityMap]
[itemVisibilityMap, getItemIdentifier]
);

const itemSelectionMap = useMemo<Record<string, boolean>>(() => {
Expand All @@ -98,7 +98,7 @@ export function useNavSection<ItemType, ScopeType>(
return makeItemToPassedConditionMap(items, scope, false, getItemIdentifier);
}
return makeItemToPassedConditionMap(items, scope, handleIsSelected, getItemIdentifier);
}, [scope, itemHandler, items]);
}, [scope, itemHandler, items, getItemIdentifier]);

const isSectionSelected = useMemo(() => {
return (
Expand All @@ -116,7 +116,7 @@ export function useNavSection<ItemType, ScopeType>(
return makeItemToPassedConditionMap(items, scope, false, getItemIdentifier);
}
return makeItemToPassedConditionMap(items, scope, handleIsHighlighted, getItemIdentifier);
}, [scope, itemHandler, items]);
}, [scope, itemHandler, items, getItemIdentifier]);

const isSectionHighlighted = useMemo(() => {
return (
Expand All @@ -135,7 +135,7 @@ export function useNavSection<ItemType, ScopeType>(
return isItemVisible(item);
});
},
[groupedItems, itemVisibilityMap]
[groupedItems, isItemVisible]
);

const shouldSectionExpand = useMemo(() => {
Expand All @@ -157,7 +157,7 @@ export function useNavSection<ItemType, ScopeType>(

const subsections = useMemo(() => {
return subsectionNames?.map(s => navSectionMap.getByName(s)) || undefined;
}, [navSectionMap]);
}, [subsectionNames]);

const isAnySubsectionVisible = useMemo(() => {
if (!subsections || subsections.length === 0) {
Expand Down Expand Up @@ -187,7 +187,7 @@ export function useNavSection<ItemType, ScopeType>(
);
}
return false;
}, [scope, items, groupedItems, isVisible, isAnySubsectionVisible]);
}, [scope, items, groupedItems, isVisible, isAnySubsectionVisible, isItemVisible, isSectionInitialized]);

return {
name,
Expand Down

0 comments on commit a1f6124

Please sign in to comment.