Skip to content

Commit c5a08da

Browse files
committed
chore(docs): Suppress hydration warning for App Size
1 parent 5db9a9b commit c5a08da

File tree

3 files changed

+16
-4
lines changed

3 files changed

+16
-4
lines changed

packages/documentation/src/components/Code/CodeBlock.tsx

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,21 @@ export default forwardRef<HTMLPreElement, CodeBlockProps>(function CodeBlock(
2525
children: propChildren,
2626
highlight = true,
2727
lineNumbers = false,
28+
suppressHydrationWarning = false,
2829
...props
2930
},
3031
ref
3132
) {
3233
const children = useMemo(() => {
3334
if (!highlight || typeof propChildren !== "string") {
34-
return <Code inline={false}>{propChildren}</Code>;
35+
return (
36+
<Code
37+
inline={false}
38+
suppressHydrationWarning={suppressHydrationWarning}
39+
>
40+
{propChildren}
41+
</Code>
42+
);
3543
}
3644

3745
return (
@@ -40,9 +48,11 @@ export default forwardRef<HTMLPreElement, CodeBlockProps>(function CodeBlock(
4048
dangerouslySetInnerHTML={{
4149
__html: highlightCode(propChildren, language),
4250
}}
51+
suppressHydrationWarning={suppressHydrationWarning}
4352
/>
4453
);
45-
}, [propChildren, highlight, language]);
54+
}, [highlight, propChildren, language, suppressHydrationWarning]);
55+
4656
return (
4757
<pre
4858
{...props}

packages/documentation/src/components/Demos/Utils/AppSizeListenerExample.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ function CurrentSize(): ReactElement {
99
return (
1010
<TextContainer>
1111
<Text type="headline-6">The current app size is:</Text>
12-
<CodeBlock language="json">{JSON.stringify(context, null, 2)}</CodeBlock>
12+
<CodeBlock language="json" suppressHydrationWarning>
13+
{JSON.stringify(context, null, 2)}
14+
</CodeBlock>
1315
</TextContainer>
1416
);
1517
}

packages/documentation/src/components/Demos/Utils/ResizeListenerExample.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export default function ResizeListenerExample(): ReactElement {
4040
/>
4141
)}
4242
<Text>The current app size is:</Text>
43-
<CodeBlock>{size}px</CodeBlock>
43+
<CodeBlock suppressHydrationWarning>{size}px</CodeBlock>
4444
</>
4545
);
4646
}

0 commit comments

Comments
 (0)