You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by "lyndsiWilliams (via GitHub)" <gi...@apache.org> on 2023/01/27 01:10:32 UTC

[GitHub] [superset] lyndsiWilliams commented on a diff in pull request #18989: fix(frontend react key warnings): add uniq keys to JSX elements

lyndsiWilliams commented on code in PR #18989:
URL: https://github.com/apache/superset/pull/18989#discussion_r1088491139


##########
superset-frontend/src/views/CRUD/welcome/Welcome.tsx:
##########
@@ -132,13 +132,25 @@ const WelcomeNav = styled.div`
   }
 `;
 
-export const LoadingCards = ({ cover }: LoadingProps) => (
-  <CardContainer showThumbnails={cover} className="loading-cards">
-    {[...new Array(loadingCardCount)].map(() => (
-      <ListViewCard cover={cover ? false : <></>} description="" loading />
-    ))}
-  </CardContainer>
-);
+export const LoadingCards = ({ cover }: LoadingProps) => {
+  const listViewCards = [];
+  for (let i = 0; i < loadingCardCount; i += 1) {
+    listViewCards.push(
+      <ListViewCard
+        key={i}
+        cover={cover ? false : <></>}
+        description=""
+        loading
+      />,
+    );
+  }
+
+  return (
+    <CardContainer showThumbnails={cover} className="loading-cards">
+      {listViewCards}
+    </CardContainer>
+  );
+};

Review Comment:
   ```suggestion
   export const LoadingCards = ({ cover }: LoadingProps) => (
     <CardContainer showThumbnails={cover} className="loading-cards">
       {[...new Array(loadingCardCount)].map((element, index) => (
         <ListViewCard
           key={index}
           cover={cover ? false : <></>}
           description=""
           loading
         />
       ))}
     </CardContainer>
   );
   ```
   Would this work the same if you used the iterator in the original `.map`?



-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org