Skip to content

Commit

Permalink
(fix) Add keys to visit attribute tags (#2137)
Browse files Browse the repository at this point in the history
Fixes a React keys warning for visit attribute tags in the Patient header.
  • Loading branch information
denniskigen authored Dec 6, 2024
1 parent 245a01a commit 077730b
Showing 1 changed file with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import React from 'react';
import { Tag } from '@carbon/react';
import { formatDate, useConfig } from '@openmrs/esm-framework';
import { type ChartConfig } from '../config-schema';
import { useVisitOrOfflineVisit } from '@openmrs/esm-patient-common-lib';
import { type ChartConfig } from '../config-schema';

interface VisitAttributeTagsProps {
patientUuid: string;
Expand All @@ -28,7 +28,7 @@ const getAttributeValue = (attributeType, value) => {

const VisitAttributeTags: React.FC<VisitAttributeTagsProps> = ({ patientUuid }) => {
const { currentVisit } = useVisitOrOfflineVisit(patientUuid);
const { visitAttributeTypes } = useConfig() as ChartConfig;
const { visitAttributeTypes } = useConfig<ChartConfig>();

return (
<>
Expand All @@ -37,7 +37,11 @@ const VisitAttributeTags: React.FC<VisitAttributeTagsProps> = ({ patientUuid })
(attribute) =>
visitAttributeTypes.find(({ uuid }) => attribute?.attributeType?.uuid === uuid)?.displayInThePatientBanner,
)
.map((attribute) => <Tag type="gray">{getAttributeValue(attribute?.attributeType, attribute?.value)}</Tag>)}
.map((attribute) => (
<Tag key={attribute?.attributeType?.uuid} type="gray">
{getAttributeValue(attribute?.attributeType, attribute?.value)}
</Tag>
))}
</>
);
};
Expand Down

0 comments on commit 077730b

Please sign in to comment.