Skip to content

Commit

Permalink
add uuid package for more unique key props
Browse files Browse the repository at this point in the history
  • Loading branch information
sar-mko committed Sep 30, 2024
1 parent 695a2d3 commit 0584264
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 10 deletions.
15 changes: 14 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
"firebase": "^10.12.5",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"react-router-dom": "^6.26.0"
"react-router-dom": "^6.26.0",
"uuid": "^10.0.0"
},
"devDependencies": {
"@nabla/vite-plugin-eslint": "^2.0.4",
Expand Down
8 changes: 4 additions & 4 deletions src/views/Home.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import './Home.css';
import { SingleList } from '../components';
import { useState } from 'react';
import { Fragment, useState } from 'react';
import { createList, useAuth } from '../api';
import { useNavigate } from 'react-router-dom';

Expand Down Expand Up @@ -40,15 +40,15 @@ export function Home({ data, setListPath }) {
<ul>
{data &&
data.map((list) => {
const uniqueId = crypto.randomUUID();
return (
<>
<Fragment key={uniqueId}>
<SingleList
key={crypto.randomUUID()}
name={list.name}
setListPath={setListPath}
path={list.path}
/>
</>
</Fragment>
);
})}
</ul>
Expand Down
9 changes: 5 additions & 4 deletions src/views/List.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { ListItem } from '../components';
import { useState, useEffect } from 'react';
import { useState, useEffect, Fragment } from 'react';
import BasicModal from './Modal';
import { comparePurchaseUrgency } from '../api';
import { v4 as uuidv4 } from 'uuid';

export function List({ data, userId }) {
const [filterVal, setFilterVal] = useState('');
Expand Down Expand Up @@ -82,14 +83,14 @@ export function List({ data, userId }) {
<ul>
{filteredObject &&
Object.entries(filteredObject).map(([timeBucket, list]) => (
<>
<Fragment key={uuidv4()}>
<div>
<h3>{labels[timeBucket]}</h3>
</div>
{list.map((item) => (
<ListItem key={item.id} item={item} />
<ListItem item={item} key={uuidv4()} />
))}
</>
</Fragment>
))}
</ul>
</>
Expand Down

0 comments on commit 0584264

Please sign in to comment.