Skip to content

Commit 614c780

Browse files
committed
test(rsc): add hydration mismatch example
1 parent 0318334 commit 614c780

File tree

4 files changed

+25
-1
lines changed

4 files changed

+25
-1
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
'use client'
2+
3+
export function Mismatch() {
4+
const value = typeof window !== 'undefined' ? 'browser' : 'ssr'
5+
return <>[{value}]</>
6+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { Mismatch } from './client'
2+
3+
export function TestHydrationMismatch(props: { url: URL }) {
4+
const show = props.url.searchParams.has('test-hydration-mismatch')
5+
return (
6+
<div>
7+
<span>test-hydration-mismatch</span>{' '}
8+
{show ? (
9+
<a href="?">hide</a>
10+
) : (
11+
<a href="?test-hydration-mismatch">show</a>
12+
)}{' '}
13+
{show && <Mismatch />}
14+
</div>
15+
)
16+
}

packages/plugin-rsc/examples/basic/src/routes/root.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import { TestTailwindClient } from './tailwind/client'
2727
import { TestTailwindServer } from './tailwind/server'
2828
import { TestTemporaryReference } from './temporary-reference/client'
2929
import { TestUseCache } from './use-cache/server'
30+
import { TestHydrationMismatch } from './hydration-mismatch/server'
3031

3132
export function Root(props: { url: URL }) {
3233
return (
@@ -47,6 +48,7 @@ export function Root(props: { url: URL }) {
4748
<TestCssClientNoSsr url={props.url} />
4849
<TestTailwindClient />
4950
<TestTailwindServer />
51+
<TestHydrationMismatch url={props.url} />
5052
<TestHmrClientDep />
5153
<TestTemporaryReference />
5254
<TestServerActionError />

packages/plugin-rsc/examples/basic/src/styles.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@ input {
99
}
1010

1111
a {
12-
@apply text-gray-500 underline hover:text-gray-700;
12+
@apply text-gray-500 underline hover:text-gray-700 cursor-pointer;
1313
}

0 commit comments

Comments
 (0)