File tree Expand file tree Collapse file tree 3 files changed +11
-9
lines changed
react-client/src/__tests__ Expand file tree Collapse file tree 3 files changed +11
-9
lines changed Original file line number Diff line number Diff line change @@ -513,9 +513,9 @@ describe('ReactFlight', () => {
513513 } ) ;
514514
515515 describe ( 'Hooks' , ( ) => {
516- function DivWithId ( ) {
516+ function DivWithId ( { children } ) {
517517 const id = React . useId ( ) ;
518- return < div prop = { id } / >;
518+ return < div prop = { id } > { children } </ div > ;
519519 }
520520
521521 it ( 'should support useId' , ( ) => {
@@ -534,8 +534,8 @@ describe('ReactFlight', () => {
534534 } ) ;
535535 expect ( ReactNoop ) . toMatchRenderedOutput (
536536 < >
537- < div prop = ":F1 :" />
538- < div prop = ":F2 :" />
537+ < div prop = ":S1 :" />
538+ < div prop = ":S2 :" />
539539 </ > ,
540540 ) ;
541541 } ) ;
@@ -558,8 +558,8 @@ describe('ReactFlight', () => {
558558 } ) ;
559559 expect ( ReactNoop ) . toMatchRenderedOutput (
560560 < >
561- < div prop = ":fooF1 :" />
562- < div prop = ":fooF2 :" />
561+ < div prop = ":fooS1 :" />
562+ < div prop = ":fooS2 :" />
563563 </ > ,
564564 ) ;
565565 } ) ;
Original file line number Diff line number Diff line change @@ -105,11 +105,12 @@ export function getCurrentCache() {
105105
106106function useId(): string {
107107 if ( currentRequest === null ) {
108- throw new Error ( 'useId can only be used while React is rendering. ' ) ;
108+ throw new Error ( 'useId can only be used while React is rendering' ) ;
109109 }
110110 const prefix = currentRequest.identifierPrefix
111111 ? currentRequest.identifierPrefix
112112 : '';
113113 const id = currentRequest.identifierCount++;
114- return ':' + prefix + 'F' + id.toString(32) + ':';
114+ // use 'S' for Flight components to distinguish from 'R' and 'r' in Fizz/Client
115+ return ':' + prefix + 'S' + id.toString(32) + ':';
115116}
Original file line number Diff line number Diff line change 416416 "428" : " useServerContext is only supported while rendering." ,
417417 "429" : " ServerContext: %s already defined" ,
418418 "430" : " ServerContext can only have a value prop and children. Found: %s" ,
419- "431" : " React elements are not allowed in ServerContext"
419+ "431" : " React elements are not allowed in ServerContext" ,
420+ "432" : " useId can only be used while React is rendering"
420421}
You can’t perform that action at this time.
0 commit comments