File tree Expand file tree Collapse file tree 2 files changed +29
-1
lines changed Expand file tree Collapse file tree 2 files changed +29
-1
lines changed Original file line number Diff line number Diff line change @@ -16,6 +16,7 @@ let ReactDOMFizzServer;
16
16
let Stream ;
17
17
let Suspense ;
18
18
let useId ;
19
+ let useState ;
19
20
let document ;
20
21
let writable ;
21
22
let container ;
@@ -35,6 +36,7 @@ describe('useId', () => {
35
36
Stream = require ( 'stream' ) ;
36
37
Suspense = React . Suspense ;
37
38
useId = React . useId ;
39
+ useState = React . useState ;
38
40
39
41
// Test Environment
40
42
const jsdom = new JSDOM (
@@ -342,6 +344,32 @@ describe('useId', () => {
342
344
` ) ;
343
345
} ) ;
344
346
347
+ test ( 'local render phase updates' , async ( ) => {
348
+ function App ( { swap} ) {
349
+ const [ count , setCount ] = useState ( 0 ) ;
350
+ if ( count < 3 ) {
351
+ setCount ( count + 1 ) ;
352
+ }
353
+ return useId ( ) ;
354
+ }
355
+
356
+ await serverAct ( async ( ) => {
357
+ const { pipe} = ReactDOMFizzServer . renderToPipeableStream ( < App /> ) ;
358
+ pipe ( writable ) ;
359
+ } ) ;
360
+ await clientAct ( async ( ) => {
361
+ ReactDOM . hydrateRoot ( container , < App /> ) ;
362
+ } ) ;
363
+ expect ( container ) . toMatchInlineSnapshot ( `
364
+ <div
365
+ id="container"
366
+ >
367
+ R:0
368
+ <!-- -->
369
+ </div>
370
+ ` ) ;
371
+ } ) ;
372
+
345
373
test ( 'basic incremental hydration' , async ( ) => {
346
374
function App ( ) {
347
375
return (
Original file line number Diff line number Diff line change @@ -199,7 +199,7 @@ export function finishHooks(
199
199
// work-in-progress hooks and applying the additional updates on top. Keep
200
200
// restarting until no more updates are scheduled.
201
201
didScheduleRenderPhaseUpdate = false ;
202
- // TODO: Reset localIdCounter
202
+ localIdCounter = 0 ;
203
203
numberOfReRenders += 1 ;
204
204
205
205
// Start over from the beginning of the list
You can’t perform that action at this time.
0 commit comments