Skip to content

Commit

Permalink
condition for suppressHydrationWarning
Browse files Browse the repository at this point in the history
  • Loading branch information
krzotki committed Jul 31, 2024
1 parent a6208ea commit 7a1e840
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
11 changes: 10 additions & 1 deletion src/components/icons/Icon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -597,7 +597,16 @@ const Icon = ({
}),
}}
>
<text id={titleId} visibility="hidden" suppressHydrationWarning>
<text
id={titleId}
visibility="hidden"
// fix for Property 'suppressHydrationWarning' does not exist on type 'SVGProps<SVGSVGTextElement>'
{...{
...(React.version.startsWith('18') && {
suppressHydrationWarning: true,
}),
}}
>
{title || defaultTitle}
</text>
{description && <desc id={descId}>{description}</desc>}
Expand Down
11 changes: 10 additions & 1 deletion src/components/subject-icons/SubjectIcon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,16 @@ const SubjectIcon = ({
}),
}}
>
<text id={titleId} visibility="hidden" suppressHydrationWarning>
<text
id={titleId}
visibility="hidden"
// fix for Property 'suppressHydrationWarning' does not exist on type 'SVGProps<SVGSVGTextElement>'
{...{
...(React.version.startsWith('18') && {
suppressHydrationWarning: true,
}),
}}
>
{title || defaultTitle}
</text>
<use xlinkHref={iconType} aria-hidden="true" />
Expand Down

0 comments on commit 7a1e840

Please sign in to comment.