Skip to content

Commit

Permalink
Fix failing React 16/17 snapshots
Browse files Browse the repository at this point in the history
  • Loading branch information
cee-chen committed Feb 1, 2024
1 parent d32b25b commit 64ab4d8
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/components/highlight/_highlight_first.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,12 @@ export const HighlightFirst: FunctionComponent<_SharedSubcomponentProps> = memo(
);

return (
// Note: React 16/17 will render empty strings in the DOM. The
// `|| undefined` prevents this & keeps snapshots the same for all versions
<>
{preMatch}
{preMatch || undefined}
<HighlightComponent>{match}</HighlightComponent>
{postMatch}
{postMatch || undefined}
</>
);
}
Expand Down

0 comments on commit 64ab4d8

Please sign in to comment.