Repository navigation
fix: replace index-based React keys with stable identifiers #209
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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -77,8 +77,8 @@ export function Navigation({ items, className, ...props }: NavigationProps) { | |
| return ( | ||
| <nav className="bg-nav-bg" {...props}> | ||
| <ul className="flex items-center gap-nav-gap"> | ||
| {items.map((item, index) => ( | ||
| <NavigationItem key={index} item={item} /> | ||
| {items.map((item) => ( | ||
| <NavigationItem key={slugify(item.title)} item={item} /> | ||
| ))} | ||
|
Comment on lines
+80
to
82
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 馃Ч Nitpick | 馃數 Trivial 馃З Analysis chain馃弫 Script executed: #!/bin/bash
# Find navigation-related files and data definitions
find apps/frontend-demo -type f -name "*.ts" -o -name "*.tsx" -o -name "*.json" | \
xargs grep -l "navigation\|nav.*item" -i | head -20Repository: NMIT-WR/new-engine Length of output: 769 馃弫 Script executed: #!/bin/bash
# Look for the navigation.tsx file and check its structure
if [ -f "apps/frontend-demo/src/components/molecules/navigation.tsx" ]; then
echo "=== Navigation.tsx file found ==="
cat "apps/frontend-demo/src/components/molecules/navigation.tsx"
else
echo "File not found. Searching for navigation files..."
find . -name "navigation.tsx" -o -name "navigation.ts" | grep -v node_modules
fiRepository: NMIT-WR/new-engine Length of output: 2806 馃弫 Script executed: #!/bin/bash
# Search for where navigation items/data are defined
rg "export.*nav.*items|navigation.*:.*\[" --type ts --type tsx -A 10 | head -100Repository: NMIT-WR/new-engine Length of output: 89 馃弫 Script executed: #!/bin/bash
# Find files that import/use Navigation component
rg "import.*Navigation|<Navigation" --type ts --type tsx -B 2 -A 5 | head -150Repository: NMIT-WR/new-engine Length of output: 89 馃弫 Script executed: #!/bin/bash
# Find files that import or use the Navigation component
grep -r "import.*Navigation\|<Navigation" apps/frontend-demo/src --include="*.ts" --include="*.tsx" -B 2 -A 5 | head -200Repository: NMIT-WR/new-engine Length of output: 2103 馃弫 Script executed: #!/bin/bash
# Find where navigationItems is defined in header.tsx
grep -n "navigationItems" apps/frontend-demo/src/components/header.tsx -B 10 -A 2 | head -100Repository: NMIT-WR/new-engine Length of output: 1576 馃弫 Script executed: #!/bin/bash
# Find where Header component is used and where navigationItems come from
grep -r "<Header\|navigationItems:" apps/frontend-demo/src --include="*.ts" --include="*.tsx" -B 3 -A 10 | head -250Repository: NMIT-WR/new-engine Length of output: 4722 馃弫 Script executed: #!/bin/bash
# Find the full definition of categoryItems
grep -n "categoryItems" apps/frontend-demo/src/components/header-wrapper.tsx -B 30 | head -50Repository: NMIT-WR/new-engine Length of output: 1454 馃弫 Script executed: #!/bin/bash
# Check the full header-wrapper.tsx file to see the complete context
cat apps/frontend-demo/src/components/header-wrapper.tsxRepository: NMIT-WR/new-engine Length of output: 1607 馃弫 Script executed: #!/bin/bash
# Check if there are any other places where Navigation items might be used dynamically
grep -r "navigationItems\|NavItem\[\]" apps/frontend-demo/src --include="*.ts" --include="*.tsx" | grep -v "node_modules"Repository: NMIT-WR/new-engine Length of output: 1250 馃弫 Script executed: #!/bin/bash
# Extract all navigation titles to verify uniqueness
cat > /tmp/check_slugs.js << 'EOF'
const titles = [
'Dom暖',
'Produkty',
'Obl铆ben茅',
'O n谩s',
'Kontakt',
'M臎sto',
'Zimn铆',
'Obuv',
'Sport'
];
// Simple slugify approximation
function slugify(str) {
return str
.toLowerCase()
.normalize('NFD')
.replace(/[\u0300-\u036f]/g, '')
.replace(/[^a-z0-9\s-]/g, '')
.replace(/\s+/g, '-')
.replace(/-+/g, '-')
.trim();
}
const slugs = titles.map(t => ({ title: t, slug: slugify(t) }));
console.log('Title -> Slug mapping:');
slugs.forEach(s => console.log(` ${s.title} -> ${s.slug}`));
const uniqueSlugs = new Set(slugs.map(s => s.slug));
console.log(`\nTotal titles: ${titles.length}`);
console.log(`Unique slugs: ${uniqueSlugs.size}`);
if (titles.length !== uniqueSlugs.size) {
console.log('鈿狅笍 DUPLICATES FOUND!');
slugs.forEach(s => {
const count = slugs.filter(x => x.slug === s.slug).length;
if (count > 1) {
console.log(` "${s.title}" produces slug "${s.slug}" (${count} items)`);
}
});
}
EOF
node /tmp/check_slugs.jsRepository: NMIT-WR/new-engine Length of output: 282 Consider augmenting the key with additional context to prevent potential collisions. The current implementation with Note: This pattern also applies to the submenu children at line 43. 馃 Prompt for AI Agents |
||
| </ul> | ||
| </nav> | ||
|
|
||
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.
馃Ч Nitpick | 馃數 Trivial
Scope concern: Multiple unrelated changes included in this PR.
This PR includes several changes that are unrelated to the stated objective of replacing index-based React keys:
priority={true}is an optimisation changesize,value,rows, andtypeprops appears to be form structure refinementas IconTypecast is a TypeScript typing changehover:bg-transparentis a styling changeIncluding multiple concerns in a single PR makes it harder to:
Consider splitting these into separate commits or PRs aligned with the conventional commit guidelines (e.g.,
fix:for keys,style:for quotes,refactor:for form props,perf:for image priority).Also applies to: 28-29, 57-132, 150-150, 183-183
馃 Prompt for AI Agents