File tree Expand file tree Collapse file tree 1 file changed +44
-0
lines changed
packages/react-client/src/__tests__ Expand file tree Collapse file tree 1 file changed +44
-0
lines changed Original file line number Diff line number Diff line change @@ -2565,6 +2565,50 @@ describe('ReactFlight', () => {
2565
2565
) ;
2566
2566
} ) ;
2567
2567
2568
+ it ( 'can change the environment name inside a component' , async ( ) => {
2569
+ let env = 'A' ;
2570
+ function Component ( props ) {
2571
+ env = 'B' ;
2572
+ return < div > hi</ div > ;
2573
+ }
2574
+
2575
+ const transport = ReactNoopFlightServer . render (
2576
+ {
2577
+ greeting : < Component /> ,
2578
+ } ,
2579
+ {
2580
+ environmentName ( ) {
2581
+ return env ;
2582
+ } ,
2583
+ } ,
2584
+ ) ;
2585
+
2586
+ await act ( async ( ) => {
2587
+ const rootModel = await ReactNoopFlightClient . read ( transport ) ;
2588
+ const greeting = rootModel . greeting ;
2589
+ expect ( getDebugInfo ( greeting ) ) . toEqual (
2590
+ __DEV__
2591
+ ? [
2592
+ {
2593
+ name : 'Component' ,
2594
+ env : 'A' ,
2595
+ owner : null ,
2596
+ stack : gate ( flag => flag . enableOwnerStacks )
2597
+ ? ' in Object.<anonymous> (at **)'
2598
+ : undefined ,
2599
+ } ,
2600
+ {
2601
+ env : 'B' ,
2602
+ } ,
2603
+ ]
2604
+ : undefined ,
2605
+ ) ;
2606
+ ReactNoop . render ( greeting ) ;
2607
+ } ) ;
2608
+
2609
+ expect ( ReactNoop ) . toMatchRenderedOutput ( < div > hi</ div > ) ;
2610
+ } ) ;
2611
+
2568
2612
// @gate enableServerComponentLogs && __DEV__
2569
2613
it ( 'replays logs, but not onError logs' , async ( ) => {
2570
2614
function foo ( ) {
You can’t perform that action at this time.
0 commit comments