Skip to content

Commit 1a88cd1

Browse files
committed
test(rsc): test useId
1 parent 4672651 commit 1a88cd1

File tree

4 files changed

+28
-0
lines changed

4 files changed

+28
-0
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ import { TestTailwind } from './tailwind'
4444
import { TestHmrClientDep2 } from './hmr-client-dep2/client'
4545
import { TestHmrClientDep3 } from './hmr-client-dep3/server'
4646
import { TestChunk2 } from './chunk2/server'
47+
import { TestUseId } from './use-id/server'
4748

4849
export function Root(props: { url: URL }) {
4950
return (
@@ -101,6 +102,7 @@ export function Root(props: { url: URL }) {
101102
<TestTreeShakeServer />
102103
<TestClientChunkServer />
103104
<TestChunk2 />
105+
<TestUseId />
104106
</body>
105107
</html>
106108
)
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
'use client'
2+
3+
import { useId } from 'react'
4+
5+
export function TestUseIdClient() {
6+
const id = useId()
7+
return <>test-useId-client: {id}</>
8+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { useId } from 'react'
2+
import { TestUseIdClient } from './client'
3+
4+
export function TestUseId() {
5+
return (
6+
<div data-testid="use-id">
7+
<TestUseIdServer />
8+
|
9+
<TestUseIdClient />
10+
</div>
11+
)
12+
}
13+
14+
function TestUseIdServer() {
15+
const id = useId()
16+
return <>test-useId-server: {id}</>
17+
}

packages/plugin-rsc/examples/starter/src/client.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import React from 'react'
44

55
export function ClientCounter() {
66
const [count, setCount] = React.useState(0)
7+
console.log('[useId]', React.useId())
78

89
return (
910
<button onClick={() => setCount((count) => count + 1)}>

0 commit comments

Comments
 (0)