Browse Source

Fix Selectors to not give error if not fetched yet (#2075)

Mgrdich 3 năm trước cách đây
mục cha
commit
c42858e722
1 tập tin đã thay đổi với 3 bổ sung4 xóa
  1. 3 4
      kafka-ui-react-app/src/redux/reducers/topics/selectors.ts

+ 3 - 4
kafka-ui-react-app/src/redux/reducers/topics/selectors.ts

@@ -138,7 +138,7 @@ const getTopicName = (_: RootState, topicName: TopicName) => topicName;
 export const getTopicByName = createSelector(
   getTopicMap,
   getTopicName,
-  (topics, topicName) => topics[topicName]
+  (topics, topicName) => topics[topicName] || {}
 );
 
 export const getPartitionsByTopicName = createSelector(
@@ -201,9 +201,8 @@ export const getIsTopicInternal = createSelector(
 );
 
 export const getTopicConsumerGroups = createSelector(
-  getTopicMap,
-  getTopicName,
-  (topics, topicName) => topics[topicName].consumerGroups || []
+  getTopicByName,
+  ({ consumerGroups }) => consumerGroups || []
 );
 
 export const getMessageSchemaByTopicName = createSelector(