Questions tagged [react-key-index]
22 questions
2
votes
2 answers
What if there is no opportunity to create unique keys?
I have a complex data set, so I will show a very simplified version for an example.
Input data:
const data = [
{
type: "input",
caption: "Name",
defaultValue: "John Smith"
},
{
type: "input",
caption: "Name",
…

Ruslan Neck
- 59
- 7
2
votes
1 answer
React keys - rendering 2 duplicate items in a list- how to avoid same key warning as same items are intended without using index as key?
I have a gallery of items. 2 items will always be the same for a memory card game (remembering 2 matching images). Now if I map through I get the error that each child should have unique key since I give id as the key. 2 of the items I render,…

javascripting
- 1,135
- 4
- 25
- 46
2
votes
2 answers
react-key-index sample example does not work
I would like to use react-key-index extension in order to generate unique id's.
I was trying to implement their sample example, but no matter what I do, it still throws me the same error:
TypeError: Hashids is not a constructor
link:…

RadekAdler
- 79
- 1
- 1
- 8
1
vote
2 answers
How does react key works
I read this article about 'why using index as a key is an anti pattern' and got curious why my project works so well with index based key matrix.
I worked on tetris project, and every second, matrix with 20 * 24 cells re-render and move tetromino.…

lcpnine
- 477
- 1
- 7
- 16
1
vote
0 answers
React key prop within wrapper
While looking through our code base, I found code that looks a bit like this:
const Carousel = ({ items }) => {
return (
{items.map((item) => (
…

p.s.w.g
- 146,324
- 30
- 291
- 331
1
vote
1 answer
Reactjs Encountered two children with the same key, `NaN`. Keys should be unique
I have tried different things to eliminate Encountered two children with the same key, NaN. Keys should be unique and this is partial log:
in DynamicFields (at TableHeader.js)
in th (at TableHeader.js)
in TableHeader
Which is basically this bit of…

brg
- 3,915
- 8
- 37
- 66
1
vote
3 answers
Warning: Each child in a list should have a unique "key" prop. Even after setting the key already
I'm using react in front-end and node, express and mongoose in backend.
I have already made a key={uniqueid} in the files but still I'm getting the error.
Here is the full error(s):
index.js:1 Warning: Each child in a list should have a unique "key"…

KenwaySharma
- 177
- 1
- 1
- 11
1
vote
2 answers
React keys with string and index
As per React docs, they are not recommending to use the key as an index. but is there any issue with using the index and a string value. like below one,
transactionDetail.map((item,index) =>
{trName}
)
is…
Rahul N R
- 23
- 1
- 4
1
vote
1 answer
Does useMemo have any effect on keyed components?
When working with a dynamic number of components, React asks developers to provide a unique key, lest this error is thrown:
Each child in a list should have a unique "key" prop
Say that each child shows a different icon and label based upon some…

Paul Razvan Berg
- 16,949
- 9
- 76
- 114
0
votes
1 answer
Why does React.createPortal allow key like list items, whereas other things like doesn't?
I have seen some apis in ReactJs to allow keys, e.g. , but at the same time doesn't have keys.
Now specifically why does React.createPortal allow key like list items?
My research: I didn't find much on SO or google,…

user31782
- 7,087
- 14
- 68
- 143
0
votes
1 answer
how to define keys within div class of react elements?
I am working on a form in react-Js as a beginner. During debugging I came to know the problem could be not defining the unique keys for every field in the form. I am not able to see the values changing in the field when adding new records in the…

Laila
- 13
- 4
0
votes
1 answer
React remove items from the shopping cart at index using the useCallback hook
I am trying to add a functionality that remove an item from the shopping cart component by clicking the onClick that fires the removeProductFromCartAtIndex useCallback function.
So far I managed to add items to the shopping cart successfully but…
0
votes
1 answer
How unique must a key/id be in React?
So, i usually make super-duper unique ids and keys for components that need it. But I wonder, how unique do they need to be? If they don't live in the same parent, is it important that they are different?
Please share you experience and thoughts :)

Sanne Wintrén
- 359
- 1
- 4
- 12
0
votes
2 answers
"react" Each child in a list should have a unique "key" prop
An error seems to occur because the key value is not entered in the map function, but I do not know how to modify the code.
The array is structured like this:
const tabContArr=[
{
tabTitle:(

skksks
- 53
- 1
- 2
- 8
0
votes
4 answers
ReactJS keep asking for key: Warning: Each child in a list should have a unique "key" prop. Check the render method of `PostCard`
i don't know why react keep asking for the key even when the key is added.
i have a component that render some posts but each posts is rendered in it's own component and it's inside a component that come from Swiper
my component look like…

dukizwe
- 160
- 3
- 9