mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
Add component storage async context
This will store owner on a per component basis.
This commit is contained in:
committed by
Rick Hanlon
parent
88e47069c1
commit
a282ee0950
@@ -8,6 +8,7 @@
|
||||
*/
|
||||
|
||||
import type {Request} from 'react-server/src/ReactFlightServer';
|
||||
import type {ReactComponentInfo} from 'shared/ReactTypes';
|
||||
|
||||
export * from '../ReactFlightServerConfigBundlerCustom';
|
||||
|
||||
@@ -23,6 +24,10 @@ export const isPrimaryRenderer = false;
|
||||
export const supportsRequestStorage = false;
|
||||
export const requestStorage: AsyncLocalStorage<Request | void> = (null: any);
|
||||
|
||||
export const supportsComponentStorage = false;
|
||||
export const componentStorage: AsyncLocalStorage<ReactComponentInfo | void> =
|
||||
(null: any);
|
||||
|
||||
export function createHints(): any {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -6,15 +6,18 @@
|
||||
*
|
||||
* @flow
|
||||
*/
|
||||
import {AsyncLocalStorage} from 'async_hooks';
|
||||
|
||||
import type {Request} from 'react-server/src/ReactFlightServer';
|
||||
import type {ReactComponentInfo} from 'shared/ReactTypes';
|
||||
|
||||
export * from 'react-server-dom-esm/src/ReactFlightServerConfigESMBundler';
|
||||
export * from 'react-dom-bindings/src/server/ReactFlightServerConfigDOM';
|
||||
|
||||
export const supportsRequestStorage = true;
|
||||
export const requestStorage: AsyncLocalStorage<Request | void> =
|
||||
new AsyncLocalStorage();
|
||||
export const supportsRequestStorage = false;
|
||||
export const requestStorage: AsyncLocalStorage<Request | void> = (null: any);
|
||||
|
||||
export const supportsComponentStorage = false;
|
||||
export const componentStorage: AsyncLocalStorage<ReactComponentInfo | void> =
|
||||
(null: any);
|
||||
|
||||
export * from '../ReactFlightServerConfigDebugNoop';
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
*/
|
||||
|
||||
import type {Request} from 'react-server/src/ReactFlightServer';
|
||||
import type {ReactComponentInfo} from 'shared/ReactTypes';
|
||||
|
||||
export * from 'react-server-dom-turbopack/src/ReactFlightServerConfigTurbopackBundler';
|
||||
export * from 'react-dom-bindings/src/server/ReactFlightServerConfigDOM';
|
||||
@@ -15,4 +16,8 @@ export * from 'react-dom-bindings/src/server/ReactFlightServerConfigDOM';
|
||||
export const supportsRequestStorage = false;
|
||||
export const requestStorage: AsyncLocalStorage<Request | void> = (null: any);
|
||||
|
||||
export const supportsComponentStorage = false;
|
||||
export const componentStorage: AsyncLocalStorage<ReactComponentInfo | void> =
|
||||
(null: any);
|
||||
|
||||
export * from '../ReactFlightServerConfigDebugNoop';
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
*/
|
||||
|
||||
import type {Request} from 'react-server/src/ReactFlightServer';
|
||||
import type {ReactComponentInfo} from 'shared/ReactTypes';
|
||||
|
||||
export * from 'react-server-dom-webpack/src/ReactFlightServerConfigWebpackBundler';
|
||||
export * from 'react-dom-bindings/src/server/ReactFlightServerConfigDOM';
|
||||
@@ -15,4 +16,8 @@ export * from 'react-dom-bindings/src/server/ReactFlightServerConfigDOM';
|
||||
export const supportsRequestStorage = false;
|
||||
export const requestStorage: AsyncLocalStorage<Request | void> = (null: any);
|
||||
|
||||
export const supportsComponentStorage = false;
|
||||
export const componentStorage: AsyncLocalStorage<ReactComponentInfo | void> =
|
||||
(null: any);
|
||||
|
||||
export * from '../ReactFlightServerConfigDebugNoop';
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
*/
|
||||
|
||||
import type {Request} from 'react-server/src/ReactFlightServer';
|
||||
import type {ReactComponentInfo} from 'shared/ReactTypes';
|
||||
|
||||
export * from '../ReactFlightServerConfigBundlerCustom';
|
||||
export * from 'react-dom-bindings/src/server/ReactFlightServerConfigDOM';
|
||||
@@ -15,4 +16,8 @@ export * from 'react-dom-bindings/src/server/ReactFlightServerConfigDOM';
|
||||
export const supportsRequestStorage = false;
|
||||
export const requestStorage: AsyncLocalStorage<Request | void> = (null: any);
|
||||
|
||||
export const supportsComponentStorage = false;
|
||||
export const componentStorage: AsyncLocalStorage<ReactComponentInfo | void> =
|
||||
(null: any);
|
||||
|
||||
export * from '../ReactFlightServerConfigDebugNoop';
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
* @flow
|
||||
*/
|
||||
import type {Request} from 'react-server/src/ReactFlightServer';
|
||||
import type {ReactComponentInfo} from 'shared/ReactTypes';
|
||||
|
||||
export * from 'react-server-dom-turbopack/src/ReactFlightServerConfigTurbopackBundler';
|
||||
export * from 'react-dom-bindings/src/server/ReactFlightServerConfigDOM';
|
||||
@@ -16,6 +17,11 @@ export const supportsRequestStorage = typeof AsyncLocalStorage === 'function';
|
||||
export const requestStorage: AsyncLocalStorage<Request | void> =
|
||||
supportsRequestStorage ? new AsyncLocalStorage() : (null: any);
|
||||
|
||||
export const supportsComponentStorage: boolean =
|
||||
__DEV__ && supportsRequestStorage;
|
||||
export const componentStorage: AsyncLocalStorage<ReactComponentInfo | void> =
|
||||
supportsComponentStorage ? new AsyncLocalStorage() : (null: any);
|
||||
|
||||
// We use the Node version but get access to async_hooks from a global.
|
||||
import type {HookCallbacks, AsyncHook} from 'async_hooks';
|
||||
export const createAsyncHook: HookCallbacks => AsyncHook =
|
||||
|
||||
@@ -6,7 +6,9 @@
|
||||
*
|
||||
* @flow
|
||||
*/
|
||||
|
||||
import type {Request} from 'react-server/src/ReactFlightServer';
|
||||
import type {ReactComponentInfo} from 'shared/ReactTypes';
|
||||
|
||||
export * from 'react-server-dom-webpack/src/ReactFlightServerConfigWebpackBundler';
|
||||
export * from 'react-dom-bindings/src/server/ReactFlightServerConfigDOM';
|
||||
@@ -16,6 +18,11 @@ export const supportsRequestStorage = typeof AsyncLocalStorage === 'function';
|
||||
export const requestStorage: AsyncLocalStorage<Request | void> =
|
||||
supportsRequestStorage ? new AsyncLocalStorage() : (null: any);
|
||||
|
||||
export const supportsComponentStorage: boolean =
|
||||
__DEV__ && supportsRequestStorage;
|
||||
export const componentStorage: AsyncLocalStorage<ReactComponentInfo | void> =
|
||||
supportsComponentStorage ? new AsyncLocalStorage() : (null: any);
|
||||
|
||||
// We use the Node version but get access to async_hooks from a global.
|
||||
import type {HookCallbacks, AsyncHook} from 'async_hooks';
|
||||
export const createAsyncHook: HookCallbacks => AsyncHook =
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
*/
|
||||
|
||||
import type {Request} from 'react-server/src/ReactFlightServer';
|
||||
import type {ReactComponentInfo} from 'shared/ReactTypes';
|
||||
|
||||
export * from '../ReactFlightServerConfigBundlerCustom';
|
||||
export * from 'react-dom-bindings/src/server/ReactFlightServerConfigDOM';
|
||||
@@ -15,4 +16,8 @@ export * from 'react-dom-bindings/src/server/ReactFlightServerConfigDOM';
|
||||
export const supportsRequestStorage = false;
|
||||
export const requestStorage: AsyncLocalStorage<Request | void> = (null: any);
|
||||
|
||||
export const supportsComponentStorage = false;
|
||||
export const componentStorage: AsyncLocalStorage<ReactComponentInfo | void> =
|
||||
(null: any);
|
||||
|
||||
export * from '../ReactFlightServerConfigDebugNoop';
|
||||
|
||||
@@ -6,9 +6,11 @@
|
||||
*
|
||||
* @flow
|
||||
*/
|
||||
|
||||
import {AsyncLocalStorage} from 'async_hooks';
|
||||
|
||||
import type {Request} from 'react-server/src/ReactFlightServer';
|
||||
import type {ReactComponentInfo} from 'shared/ReactTypes';
|
||||
|
||||
export * from 'react-server-dom-esm/src/ReactFlightServerConfigESMBundler';
|
||||
export * from 'react-dom-bindings/src/server/ReactFlightServerConfigDOM';
|
||||
@@ -17,5 +19,9 @@ export const supportsRequestStorage = true;
|
||||
export const requestStorage: AsyncLocalStorage<Request | void> =
|
||||
new AsyncLocalStorage();
|
||||
|
||||
export const supportsComponentStorage = __DEV__;
|
||||
export const componentStorage: AsyncLocalStorage<ReactComponentInfo | void> =
|
||||
supportsComponentStorage ? new AsyncLocalStorage() : (null: any);
|
||||
|
||||
export {createHook as createAsyncHook, executionAsyncId} from 'async_hooks';
|
||||
export * from '../ReactFlightServerConfigDebugNode';
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
import {AsyncLocalStorage} from 'async_hooks';
|
||||
|
||||
import type {Request} from 'react-server/src/ReactFlightServer';
|
||||
import type {ReactComponentInfo} from 'shared/ReactTypes';
|
||||
|
||||
export * from 'react-server-dom-turbopack/src/ReactFlightServerConfigTurbopackBundler';
|
||||
export * from 'react-dom-bindings/src/server/ReactFlightServerConfigDOM';
|
||||
@@ -18,5 +19,9 @@ export const supportsRequestStorage = true;
|
||||
export const requestStorage: AsyncLocalStorage<Request | void> =
|
||||
new AsyncLocalStorage();
|
||||
|
||||
export const supportsComponentStorage = __DEV__;
|
||||
export const componentStorage: AsyncLocalStorage<ReactComponentInfo | void> =
|
||||
supportsComponentStorage ? new AsyncLocalStorage() : (null: any);
|
||||
|
||||
export {createHook as createAsyncHook, executionAsyncId} from 'async_hooks';
|
||||
export * from '../ReactFlightServerConfigDebugNode';
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
import {AsyncLocalStorage} from 'async_hooks';
|
||||
|
||||
import type {Request} from 'react-server/src/ReactFlightServer';
|
||||
import type {ReactComponentInfo} from 'shared/ReactTypes';
|
||||
|
||||
export * from 'react-server-dom-webpack/src/ReactFlightServerConfigWebpackBundler';
|
||||
export * from 'react-dom-bindings/src/server/ReactFlightServerConfigDOM';
|
||||
@@ -18,5 +19,9 @@ export const supportsRequestStorage = true;
|
||||
export const requestStorage: AsyncLocalStorage<Request | void> =
|
||||
new AsyncLocalStorage();
|
||||
|
||||
export const supportsComponentStorage = __DEV__;
|
||||
export const componentStorage: AsyncLocalStorage<ReactComponentInfo | void> =
|
||||
supportsComponentStorage ? new AsyncLocalStorage() : (null: any);
|
||||
|
||||
export {createHook as createAsyncHook, executionAsyncId} from 'async_hooks';
|
||||
export * from '../ReactFlightServerConfigDebugNode';
|
||||
|
||||
Reference in New Issue
Block a user