-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
https://durmus-w3-ecommerce.netlify.app/ #26
base: main
Are you sure you want to change the base?
https://durmus-w3-ecommerce.netlify.app/ #26
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work @mustafadurmusNl ! 👏 Let's go for the final project.
<div className="categories"> | ||
{categories.map((category, index) => ( | ||
<div | ||
key={index} // Use index as the key since categories are strings |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you mean with 'since categories are strings'? 🙂 Why could categories not be used for the key
? As long as they are unique, static values among siblings (so each li
has a different value) it is fine.
I thought key should be a numeric value not a string. And in my studies i observed that index is best practice as unique key unless the server contains a unique Id Sent from my iPhoneOn 29 Sep 2024, at 17:50, Tim Lorent ***@***.***> wrote:
@tlorent approved this pull request.
Great work @mustafadurmusNl ! 👏 Let's go for the final project.
In week3/project/ecommerce/src/CategoryList.jsx:
@@ -0,0 +1,23 @@
+/* eslint-disable react/prop-types */
+const CategoryList = ({ categories, selectedCategory, handleCategoryChange }) => {
+ if (!Array.isArray(categories)) {
+ return <div>Error: Categories data is not an array.</div>;
+ }
+
+ return (
+ <div className="categories">
+ {categories.map((category, index) => (
+ <div
+ key={index} // Use index as the key since categories are strings
What do you mean with 'since categories are strings'? 🙂 Why could categories not be used for the key? As long as they are unique, static values among siblings (so each li has a different value) it is fine.
—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you were mentioned.Message ID: ***@***.***>
|
No description provided.