Skip to content

Commit e1539bc

Browse files
committed
Split out current owner for parity with Fiber
1 parent 4b07ac0 commit e1539bc

File tree

3 files changed

+21
-11
lines changed

3 files changed

+21
-11
lines changed

packages/react-server/src/ReactFlightServer.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -87,11 +87,9 @@ import {
8787
getThenableStateAfterSuspending,
8888
resetHooksForRequest,
8989
} from './ReactFlightHooks';
90-
import {
91-
DefaultAsyncDispatcher,
92-
currentOwner,
93-
setCurrentOwner,
94-
} from './flight/ReactFlightAsyncDispatcher';
90+
import {DefaultAsyncDispatcher} from './flight/ReactFlightAsyncDispatcher';
91+
92+
import {currentOwner, setCurrentOwner} from './flight/ReactFlightCurrentOwner';
9593

9694
import {
9795
getIteratorFn,

packages/react-server/src/flight/ReactFlightAsyncDispatcher.js

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ import {resolveRequest, getCache} from '../ReactFlightServer';
1515

1616
import {disableStringRefs} from 'shared/ReactFeatureFlags';
1717

18+
import {currentOwner} from './ReactFlightCurrentOwner';
19+
1820
function resolveCache(): Map<Function, mixed> {
1921
const request = resolveRequest();
2022
if (request) {
@@ -36,8 +38,6 @@ export const DefaultAsyncDispatcher: AsyncDispatcher = ({
3638
},
3739
}: any);
3840

39-
export let currentOwner: ReactComponentInfo | null = null;
40-
4141
if (__DEV__) {
4242
DefaultAsyncDispatcher.getOwner = (): null | ReactComponentInfo => {
4343
return currentOwner;
@@ -48,7 +48,3 @@ if (__DEV__) {
4848
return null;
4949
};
5050
}
51-
52-
export function setCurrentOwner(componentInfo: null | ReactComponentInfo) {
53-
currentOwner = componentInfo;
54-
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/**
2+
* Copyright (c) Meta Platforms, Inc. and affiliates.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*
7+
* @flow
8+
*/
9+
10+
import type {ReactComponentInfo} from 'shared/ReactTypes';
11+
12+
export let currentOwner: ReactComponentInfo | null = null;
13+
14+
export function setCurrentOwner(componentInfo: null | ReactComponentInfo) {
15+
currentOwner = componentInfo;
16+
}

0 commit comments

Comments
 (0)