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;
1616let Stream ;
1717let Suspense ;
1818let useId ;
19+ let useState ;
1920let document ;
2021let writable ;
2122let container ;
@@ -35,6 +36,7 @@ describe('useId', () => {
3536 Stream = require ( 'stream' ) ;
3637 Suspense = React . Suspense ;
3738 useId = React . useId ;
39+ useState = React . useState ;
3840
3941 // Test Environment
4042 const jsdom = new JSDOM (
@@ -342,6 +344,32 @@ describe('useId', () => {
342344 ` ) ;
343345 } ) ;
344346
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+
345373 test ( 'basic incremental hydration' , async ( ) => {
346374 function App ( ) {
347375 return (
Original file line number Diff line number Diff line change @@ -199,7 +199,7 @@ export function finishHooks(
199199 // work-in-progress hooks and applying the additional updates on top. Keep
200200 // restarting until no more updates are scheduled.
201201 didScheduleRenderPhaseUpdate = false ;
202- // TODO: Reset localIdCounter
202+ localIdCounter = 0 ;
203203 numberOfReRenders += 1 ;
204204
205205 // Start over from the beginning of the list
You can’t perform that action at this time.
0 commit comments