diff --git a/packages/react-client/src/__tests__/ReactFlight-test.js b/packages/react-client/src/__tests__/ReactFlight-test.js
index 5507d4cb6b136..bd2d98736addd 100644
--- a/packages/react-client/src/__tests__/ReactFlight-test.js
+++ b/packages/react-client/src/__tests__/ReactFlight-test.js
@@ -2565,6 +2565,50 @@ describe('ReactFlight', () => {
);
});
+ it('can change the environment name inside a component', async () => {
+ let env = 'A';
+ function Component(props) {
+ env = 'B';
+ return
hi
;
+ }
+
+ const transport = ReactNoopFlightServer.render(
+ {
+ greeting: ,
+ },
+ {
+ environmentName() {
+ return env;
+ },
+ },
+ );
+
+ await act(async () => {
+ const rootModel = await ReactNoopFlightClient.read(transport);
+ const greeting = rootModel.greeting;
+ expect(getDebugInfo(greeting)).toEqual(
+ __DEV__
+ ? [
+ {
+ name: 'Component',
+ env: 'A',
+ owner: null,
+ stack: gate(flag => flag.enableOwnerStacks)
+ ? ' in Object. (at **)'
+ : undefined,
+ },
+ {
+ env: 'B',
+ },
+ ]
+ : undefined,
+ );
+ ReactNoop.render(greeting);
+ });
+
+ expect(ReactNoop).toMatchRenderedOutput(hi
);
+ });
+
// @gate enableServerComponentLogs && __DEV__
it('replays logs, but not onError logs', async () => {
function foo() {