fix annoying react error "missing unique key prop"

This commit is contained in:
Eduard Heimbuch
2020-11-13 12:51:48 +01:00
committed by René Pfeuffer
parent 2087c27671
commit 6343eddeb3
2 changed files with 9 additions and 3 deletions

View File

@@ -52,7 +52,13 @@ const SplitAndReplace: FC<Props> = ({ text, replacements }) => {
if (parts.length === 0) { if (parts.length === 0) {
return <>{parts[0]}</>; return <>{parts[0]}</>;
} }
return <>{parts}</>; return (
<>
{parts.map((part, index) => (
<React.Fragment key={index}>{part}</React.Fragment>
))}
</>
);
}; };
export default SplitAndReplace; export default SplitAndReplace;

View File

@@ -174,8 +174,8 @@ class ChangesetDetails extends React.Component<Props, State> {
const description = changesets.parseDescription(changeset.description); const description = changesets.parseDescription(changeset.description);
const id = <ChangesetId repository={repository} changeset={changeset} link={false} />; const id = <ChangesetId repository={repository} changeset={changeset} link={false} />;
const date = <DateFromNow date={changeset.date} />; const date = <DateFromNow date={changeset.date} />;
const parents = changeset._embedded.parents.map((parent: ParentChangeset) => ( const parents = changeset._embedded.parents.map((parent: ParentChangeset, index: number) => (
<ReactLink title={parent.id} to={parent.id}> <ReactLink title={parent.id} to={parent.id} key={index}>
{parent.id.substring(0, 7)} {parent.id.substring(0, 7)}
</ReactLink> </ReactLink>
)); ));