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', () => {
513
513
} ) ;
514
514
515
515
describe ( 'Hooks' , ( ) => {
516
- function DivWithId ( ) {
516
+ function DivWithId ( { children } ) {
517
517
const id = React . useId ( ) ;
518
- return < div prop = { id } / >;
518
+ return < div prop = { id } > { children } </ div > ;
519
519
}
520
520
521
521
it ( 'should support useId' , ( ) => {
@@ -534,8 +534,8 @@ describe('ReactFlight', () => {
534
534
} ) ;
535
535
expect ( ReactNoop ) . toMatchRenderedOutput (
536
536
< >
537
- < div prop = ":F1 :" />
538
- < div prop = ":F2 :" />
537
+ < div prop = ":S1 :" />
538
+ < div prop = ":S2 :" />
539
539
</ > ,
540
540
) ;
541
541
} ) ;
@@ -558,8 +558,8 @@ describe('ReactFlight', () => {
558
558
} ) ;
559
559
expect ( ReactNoop ) . toMatchRenderedOutput (
560
560
< >
561
- < div prop = ":fooF1 :" />
562
- < div prop = ":fooF2 :" />
561
+ < div prop = ":fooS1 :" />
562
+ < div prop = ":fooS2 :" />
563
563
</ > ,
564
564
) ;
565
565
} ) ;
Original file line number Diff line number Diff line change @@ -105,11 +105,12 @@ export function getCurrentCache() {
105
105
106
106
function useId(): string {
107
107
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' ) ;
109
109
}
110
110
const prefix = currentRequest.identifierPrefix
111
111
? currentRequest.identifierPrefix
112
112
: '';
113
113
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) + ':';
115
116
}
Original file line number Diff line number Diff line change 416
416
"428" : " useServerContext is only supported while rendering." ,
417
417
"429" : " ServerContext: %s already defined" ,
418
418
"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"
420
421
}
You can’t perform that action at this time.
0 commit comments