Skip to content

Commit

Permalink
fix bug in assigning row ids
Browse files Browse the repository at this point in the history
  • Loading branch information
anshuthopsee committed Nov 16, 2023
1 parent fa0b4e0 commit a5a7109
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions src/components/Configure/AddLegs.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,17 +60,21 @@ const AddLegs = () => {
};

const addLeg = () => {
const id = legs.length;
const updatedLegs = [...legs,
{
id: id,
type: type,
action: action,
strike: Number(strike),
premium: Number(premium),
selected: true
}
];
const updatedLegs = [];

for (let i = 0; i < legs.length; i++) {
updatedLegs[i] = { ...legs[i], id: i };
};

updatedLegs.push({
id: legs.length,
type: type,
action: action,
strike: Number(strike),
premium: Number(premium),
selected: true,
});

updateLegs(updatedLegs);
};

Expand Down

0 comments on commit a5a7109

Please sign in to comment.