Skip to content

Commit

Permalink
Ensure unique component keys for rendering
Browse files Browse the repository at this point in the history
  • Loading branch information
jameshadfield committed Mar 8, 2021
1 parent ddaff9e commit 0653954
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/components/tree/infoPanels/click.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,15 @@ const MutationTable = ({mutations}) => {
const [aa, bb] = [parseInt(a.slice(1, -1), 10), parseInt(b.slice(1, -1), 10)];
return aa<bb ? -1 : 1;
};
// we encode the table here (rather than via `item()`) to set component keys appropriately
return (
Object.entries(mutations)
.sort(geneSortFn)
.map(([gene, muts], index) => (
item(index === 0 ? "Mutations from root" : "", gene + ": " + muts.sort(mutSortFn).join(", ").substring(0, 200))
<tr key={gene}>
<th style={infoPanelStyles.item}>{index===0 ? "Mutations from root" : ""}</th>
<td style={infoPanelStyles.item}>{`${gene}:${muts.sort(mutSortFn).join(", ").substring(0, 200)}`}</td>
</tr>
))
);
};
Expand Down

0 comments on commit 0653954

Please sign in to comment.