Skip to content

Commit

Permalink
Add key property to list children in Highlight component
Browse files Browse the repository at this point in the history
  • Loading branch information
valentinpalkovic committed Mar 13, 2024
1 parent 49593b5 commit 55761f8
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions code/ui/manager/src/components/sidebar/SearchResults.tsx
Expand Up @@ -111,10 +111,10 @@ const Highlight: FC<PropsWithChildren<{ match?: Match }>> = React.memo(function
const { value, indices } = match;
const { nodes: result } = indices.reduce<{ cursor: number; nodes: ReactNode[] }>(
({ cursor, nodes }, [start, end], index, { length }) => {
nodes.push(<span>{value.slice(cursor, start)}</span>);
nodes.push(<Mark>{value.slice(start, end + 1)}</Mark>);
nodes.push(<span key={`${index}-1`}>{value.slice(cursor, start)}</span>);
nodes.push(<Mark key={`${index}-2`}>{value.slice(start, end + 1)}</Mark>);
if (index === length - 1) {
nodes.push(<span>{value.slice(end + 1)}</span>);
nodes.push(<span key={`${index}-3`}>{value.slice(end + 1)}</span>);
}
return { cursor: end + 1, nodes };
},
Expand Down

0 comments on commit 55761f8

Please sign in to comment.