"fixed" some keys in loops

This commit is contained in:
Djeeberjr 2021-11-14 17:40:54 +01:00
parent 0303bd3954
commit e8bf2a7947
3 changed files with 11 additions and 3 deletions

View File

@ -27,7 +27,9 @@ const CardComp: React.FC<Props> = ({card,side,onChange,onRemove}) => {
</div> </div>
<div className="border border-red-500"> <div className="border border-red-500">
{card.items.map((item,i)=> {card.items.map((item,i)=>
<div key={i}> <div
key={item + i} // FIXME: this is just a "temporary" solution. Implement propper key
>
{ItemToDisplay(item,side)} <span onClick={()=>{ {ItemToDisplay(item,side)} <span onClick={()=>{
onChange?.(new Card(card.title,card.armor,card.helmet,...card.items.filter((_,fi)=>i!==fi))) onChange?.(new Card(card.title,card.armor,card.helmet,...card.items.filter((_,fi)=>i!==fi)))
}} className="float-right cursor-pointer" >X</span> }} className="float-right cursor-pointer" >X</span>

View File

@ -21,7 +21,10 @@ const CardGroupComp: React.FC<Props> = ({cardGroup,side,onChange,onRemove}) => {
/> />
<div className="flex"> <div className="flex">
{cardGroup.cards.map((card,index) => {cardGroup.cards.map((card,index) =>
<CardComp key={index} card={card} side={side} <CardComp
key={card.toString() + index} // FIXME: this is just a "temporary" solution. Implement propper key
card={card}
side={side}
onChange={(newCard)=>{ onChange={(newCard)=>{
onChange?.(new CardGroup( onChange?.(new CardGroup(
cardGroup.numInDeck, cardGroup.numInDeck,

View File

@ -24,7 +24,10 @@ const DeckComp: React.FC<Props> = ({deck,side,title,onChange}) => {
/> </span> } /> </span> }
<div className="flex"> <div className="flex">
{deck.cardGroups.map((group,index) => {deck.cardGroups.map((group,index) =>
<CardGroupComp key={index} cardGroup={group} side={side} <CardGroupComp
key={group.toString() + index} // FIXME: this is just a "temporary" solution. Implement propper key
cardGroup={group}
side={side}
onChange={(newGroup)=>{ onChange={(newGroup)=>{
onChange?.(new Deck( onChange?.(new Deck(
deck.numDefusers, deck.numDefusers,