Error: Missing "key" prop for element in array react/jsx-key
See original GitHub issueWhen deploying on Vercel I get this deployment error.
I use this Table Component:
<Table
columnsConfig="80px 3fr 2fr 2fr 80px"
data={dataFeed3}
header={[
'',
<span>Fight</span>,
<span>Staked</span>,
<span>Action</span>,
''
]}
maxPages={3}
onPageNumberChanged={function noRefCheck(){}}
pageSize={5}
/>
Data to the data object goes from this:
const dataFeed3 = stakedFights
.map((stakedFights, index) => [<span key={index}></span>, <Link href="/fights/[address]" as={`/fights/${stakedFights.contract}`}>{`Fight `+stakedFights.contract.substring(0,6)+`...`+stakedFights.contract.substring(38,42)}</Link>,
<span>{Math.floor(Web3.utils.fromWei(((stakedFights.Staked).toString()), 'ether'))+` SLICE`}</span>,
<Button variant='outline-secondary' onClick={()=>onUnstake(stakedFights.Staked, stakedFights.contract)}>Unstake</Button>, ''])
As you can see I use the key prop in the array, so I am stuck here.
Please help.
Issue Analytics
- State:
- Created 2 years ago
- Comments:5
Top Results From Across the Web
eslint: Missing "key" prop for element in iterator (react/jsx-key)
Please take a time to notice that the Col element have an unique key. Indeed, person.id is unique throughout the map loop.
Read more >jsx-key `Missing "key" prop for element in array` when there is ...
Hello,. I just upgraded eslint-plugin-react from 7.28.0 to 7.29.0. The result is I now get a Missing "key" prop for element in array...
Read more >react_missing_key_prop - Rule | DeepScan
This rule applies when key prop is missing at each element inside the children of a React element. In React, rendering is optimized...
Read more >How to Fix 'Each child should have a unique key prop' - Webtips
The "Each child in a list should have a unique "key" prop." warning happens in React when you create a list of elements...
Read more >Lists and Keys - React
Keys help React identify which items have changed, are added, or are removed. Keys should be given to the elements inside the array...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thank you @locothedev very much for helping. It works now.
Just add key to each item inside the array .
See this example for reference
https://github.com/ethereum-boilerplate/ethereum-nft-marketplace-template/blob/main/src/views/Admin/Module/Overview/Overview.tsx#L46-L80