diff --git a/src/components/organisms/NavigatorPane/KindRenderer/ResourceCounter.tsx b/src/components/organisms/NavigatorPane/KindRenderer/ResourceCounter.tsx index 8fc6481d0e..de9a792f07 100644 --- a/src/components/organisms/NavigatorPane/KindRenderer/ResourceCounter.tsx +++ b/src/components/organisms/NavigatorPane/KindRenderer/ResourceCounter.tsx @@ -1,7 +1,7 @@ import styled from 'styled-components'; import {useAppSelector} from '@redux/hooks'; -import {navigatorResourcesSelector} from '@redux/selectors/resourceSelectors'; +import {navigatorResourcesCountSelector} from '@redux/selectors/resourceSelectors'; import {Colors, FontColors} from '@shared/styles'; @@ -13,11 +13,11 @@ type Props = { function ResourceCounter({kind, isSelected, onClick}: Props) { const isCollapsed = useAppSelector(state => state.ui.navigator.collapsedResourceKinds.includes(kind)); - const navigatorResources = useAppSelector(state => navigatorResourcesSelector(state)); + const navigatorResourcesCount = useAppSelector(navigatorResourcesCountSelector); return ( - {navigatorResources.filter(r => r.kind === kind).length} + {navigatorResourcesCount} ); } diff --git a/src/redux/selectors/resourceSelectors.ts b/src/redux/selectors/resourceSelectors.ts index 328fd5004b..4778c3c7f6 100644 --- a/src/redux/selectors/resourceSelectors.ts +++ b/src/redux/selectors/resourceSelectors.ts @@ -259,3 +259,8 @@ export const resourceNavigatorSelector = createSelector( return list; } ); + +export const navigatorResourcesCountSelector = createSelector( + resourceNavigatorSelector, + navigatorResources => navigatorResources.length +);