@samitouri / QOS-React / commits / a8c16a0040

Split Cache into its own Dispatcher (#25474)

* Missing Hooks * Remove www forks. These can use __SECRET... instead. * Move cache to separate dispatcher These will be available in more contexts than just render.

Sebastian Markbåge committed Oct 12, 2022 at 23:13 UTC a8c16a00406a204f0153c21023a04ca9a68411da
24 files changed +293 -229
packages/react-debug-tools/src/ReactDebugHooks.js
-5
@@ -101,10 +101,6 @@ function nextHook(): null | Hook {
101 return hook;
102 }
103
104 -function getCacheForType<T>(resourceType: () => T): T {
105 - throw new Error('Not implemented.');
106 -}
107 -
104 function readContext<T>(context: ReactContext<T>): T {
105 // For now we don't expose readContext usage in the hooks debugging info.
106 return context._currentValue;
@@ -331,7 +327,6 @@ function useId(): string {
327 }
328
329 const Dispatcher: DispatcherType = {
334 - getCacheForType,
330 readContext,
331 useCacheRefresh,
332 useCallback,
packages/react-reconciler/src/ReactFiberCache.new.js new
+41
@@ -0,0 +1,41 @@
1 +/**
2 + * Copyright (c) Facebook, Inc. and its 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 {CacheDispatcher} from './ReactInternalTypes';
11 +import type {Cache} from './ReactFiberCacheComponent.new';
12 +
13 +import {enableCache} from 'shared/ReactFeatureFlags';
14 +import {readContext} from './ReactFiberNewContext.new';
15 +import {CacheContext} from './ReactFiberCacheComponent.new';
16 +
17 +function getCacheSignal(): AbortSignal {
18 + if (!enableCache) {
19 + throw new Error('Not implemented.');
20 + }
21 + const cache: Cache = readContext(CacheContext);
22 + return cache.controller.signal;
23 +}
24 +
25 +function getCacheForType<T>(resourceType: () => T): T {
26 + if (!enableCache) {
27 + throw new Error('Not implemented.');
28 + }
29 + const cache: Cache = readContext(CacheContext);
30 + let cacheForType: T | void = (cache.data.get(resourceType): any);
31 + if (cacheForType === undefined) {
32 + cacheForType = resourceType();
33 + cache.data.set(resourceType, cacheForType);
34 + }
35 + return cacheForType;
36 +}
37 +
38 +export const DefaultCacheDispatcher: CacheDispatcher = {
39 + getCacheSignal,
40 + getCacheForType,
41 +};
packages/react-reconciler/src/ReactFiberCache.old.js new
+41
@@ -0,0 +1,41 @@
1 +/**
2 + * Copyright (c) Facebook, Inc. and its 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 {CacheDispatcher} from './ReactInternalTypes';
11 +import type {Cache} from './ReactFiberCacheComponent.old';
12 +
13 +import {enableCache} from 'shared/ReactFeatureFlags';
14 +import {readContext} from './ReactFiberNewContext.old';
15 +import {CacheContext} from './ReactFiberCacheComponent.old';
16 +
17 +function getCacheSignal(): AbortSignal {
18 + if (!enableCache) {
19 + throw new Error('Not implemented.');
20 + }
21 + const cache: Cache = readContext(CacheContext);
22 + return cache.controller.signal;
23 +}
24 +
25 +function getCacheForType<T>(resourceType: () => T): T {
26 + if (!enableCache) {
27 + throw new Error('Not implemented.');
28 + }
29 + const cache: Cache = readContext(CacheContext);
30 + let cacheForType: T | void = (cache.data.get(resourceType): any);
31 + if (cacheForType === undefined) {
32 + cacheForType = resourceType();
33 + cache.data.set(resourceType, cacheForType);
34 + }
35 + return cacheForType;
36 +}
37 +
38 +export const DefaultCacheDispatcher: CacheDispatcher = {
39 + getCacheSignal,
40 + getCacheForType,
41 +};
packages/react-reconciler/src/ReactFiberHooks.new.js
+1 -45
@@ -26,7 +26,6 @@ import type {
26 import type {Lanes, Lane} from './ReactFiberLane.new';
27 import type {HookFlags} from './ReactHookEffectTags';
28 import type {FiberRoot} from './ReactInternalTypes';
29 -import type {Cache} from './ReactFiberCacheComponent.new';
29 import type {Flags} from './ReactFiberFlags';
30
31 import ReactSharedInternals from 'shared/ReactSharedInternals';
@@ -122,7 +121,7 @@ import {
121 } from './ReactMutableSource.new';
122 import {logStateUpdateScheduled} from './DebugTracing';
123 import {markStateUpdateScheduled} from './ReactFiberDevToolsHook.new';
125 -import {createCache, CacheContext} from './ReactFiberCacheComponent.new';
124 +import {createCache} from './ReactFiberCacheComponent.new';
125 import {
126 createUpdate as createLegacyQueueUpdate,
127 enqueueUpdate as enqueueLegacyQueueUpdate,
@@ -2600,27 +2599,6 @@ function markUpdateInDevTools<A>(fiber, lane, action: A) {
2599 }
2600 }
2601
2603 -function getCacheSignal(): AbortSignal {
2604 - if (!enableCache) {
2605 - throw new Error('Not implemented.');
2606 - }
2607 - const cache: Cache = readContext(CacheContext);
2608 - return cache.controller.signal;
2609 -}
2610 -
2611 -function getCacheForType<T>(resourceType: () => T): T {
2612 - if (!enableCache) {
2613 - throw new Error('Not implemented.');
2614 - }
2615 - const cache: Cache = readContext(CacheContext);
2616 - let cacheForType: T | void = (cache.data.get(resourceType): any);
2617 - if (cacheForType === undefined) {
2618 - cacheForType = resourceType();
2619 - cache.data.set(resourceType, cacheForType);
2620 - }
2621 - return cacheForType;
2622 -}
2623 -
2602 export const ContextOnlyDispatcher: Dispatcher = {
2603 readContext,
2604
@@ -2644,8 +2622,6 @@ export const ContextOnlyDispatcher: Dispatcher = {
2622 unstable_isNewReconciler: enableNewReconciler,
2623 };
2624 if (enableCache) {
2647 - (ContextOnlyDispatcher: Dispatcher).getCacheSignal = getCacheSignal;
2648 - (ContextOnlyDispatcher: Dispatcher).getCacheForType = getCacheForType;
2625 (ContextOnlyDispatcher: Dispatcher).useCacheRefresh = throwInvalidHookError;
2626 }
2627 if (enableUseHook) {
@@ -2681,8 +2657,6 @@ const HooksDispatcherOnMount: Dispatcher = {
2657 unstable_isNewReconciler: enableNewReconciler,
2658 };
2659 if (enableCache) {
2684 - (HooksDispatcherOnMount: Dispatcher).getCacheSignal = getCacheSignal;
2685 - (HooksDispatcherOnMount: Dispatcher).getCacheForType = getCacheForType;
2660 // $FlowFixMe[escaped-generic] discovered when updating Flow
2661 (HooksDispatcherOnMount: Dispatcher).useCacheRefresh = mountRefresh;
2662 }
@@ -2718,8 +2692,6 @@ const HooksDispatcherOnUpdate: Dispatcher = {
2692 unstable_isNewReconciler: enableNewReconciler,
2693 };
2694 if (enableCache) {
2721 - (HooksDispatcherOnUpdate: Dispatcher).getCacheSignal = getCacheSignal;
2722 - (HooksDispatcherOnUpdate: Dispatcher).getCacheForType = getCacheForType;
2695 (HooksDispatcherOnUpdate: Dispatcher).useCacheRefresh = updateRefresh;
2696 }
2697 if (enableUseMemoCacheHook) {
@@ -2755,8 +2727,6 @@ const HooksDispatcherOnRerender: Dispatcher = {
2727 unstable_isNewReconciler: enableNewReconciler,
2728 };
2729 if (enableCache) {
2758 - (HooksDispatcherOnRerender: Dispatcher).getCacheSignal = getCacheSignal;
2759 - (HooksDispatcherOnRerender: Dispatcher).getCacheForType = getCacheForType;
2730 (HooksDispatcherOnRerender: Dispatcher).useCacheRefresh = updateRefresh;
2731 }
2732 if (enableUseHook) {
@@ -2935,8 +2905,6 @@ if (__DEV__) {
2905 unstable_isNewReconciler: enableNewReconciler,
2906 };
2907 if (enableCache) {
2938 - (HooksDispatcherOnMountInDEV: Dispatcher).getCacheSignal = getCacheSignal;
2939 - (HooksDispatcherOnMountInDEV: Dispatcher).getCacheForType = getCacheForType;
2908 (HooksDispatcherOnMountInDEV: Dispatcher).useCacheRefresh = function useCacheRefresh() {
2909 currentHookNameInDev = 'useCacheRefresh';
2910 mountHookTypesDev();
@@ -3094,8 +3062,6 @@ if (__DEV__) {
3062 unstable_isNewReconciler: enableNewReconciler,
3063 };
3064 if (enableCache) {
3097 - (HooksDispatcherOnMountWithHookTypesInDEV: Dispatcher).getCacheSignal = getCacheSignal;
3098 - (HooksDispatcherOnMountWithHookTypesInDEV: Dispatcher).getCacheForType = getCacheForType;
3065 (HooksDispatcherOnMountWithHookTypesInDEV: Dispatcher).useCacheRefresh = function useCacheRefresh() {
3066 currentHookNameInDev = 'useCacheRefresh';
3067 updateHookTypesDev();
@@ -3253,8 +3219,6 @@ if (__DEV__) {
3219 unstable_isNewReconciler: enableNewReconciler,
3220 };
3221 if (enableCache) {
3256 - (HooksDispatcherOnUpdateInDEV: Dispatcher).getCacheSignal = getCacheSignal;
3257 - (HooksDispatcherOnUpdateInDEV: Dispatcher).getCacheForType = getCacheForType;
3222 (HooksDispatcherOnUpdateInDEV: Dispatcher).useCacheRefresh = function useCacheRefresh() {
3223 currentHookNameInDev = 'useCacheRefresh';
3224 updateHookTypesDev();
@@ -3413,8 +3377,6 @@ if (__DEV__) {
3377 unstable_isNewReconciler: enableNewReconciler,
3378 };
3379 if (enableCache) {
3416 - (HooksDispatcherOnRerenderInDEV: Dispatcher).getCacheSignal = getCacheSignal;
3417 - (HooksDispatcherOnRerenderInDEV: Dispatcher).getCacheForType = getCacheForType;
3380 (HooksDispatcherOnRerenderInDEV: Dispatcher).useCacheRefresh = function useCacheRefresh() {
3381 currentHookNameInDev = 'useCacheRefresh';
3382 updateHookTypesDev();
@@ -3589,8 +3551,6 @@ if (__DEV__) {
3551 unstable_isNewReconciler: enableNewReconciler,
3552 };
3553 if (enableCache) {
3592 - (InvalidNestedHooksDispatcherOnMountInDEV: Dispatcher).getCacheSignal = getCacheSignal;
3593 - (InvalidNestedHooksDispatcherOnMountInDEV: Dispatcher).getCacheForType = getCacheForType;
3554 (InvalidNestedHooksDispatcherOnMountInDEV: Dispatcher).useCacheRefresh = function useCacheRefresh() {
3555 currentHookNameInDev = 'useCacheRefresh';
3556 mountHookTypesDev();
@@ -3776,8 +3736,6 @@ if (__DEV__) {
3736 unstable_isNewReconciler: enableNewReconciler,
3737 };
3738 if (enableCache) {
3779 - (InvalidNestedHooksDispatcherOnUpdateInDEV: Dispatcher).getCacheSignal = getCacheSignal;
3780 - (InvalidNestedHooksDispatcherOnUpdateInDEV: Dispatcher).getCacheForType = getCacheForType;
3739 (InvalidNestedHooksDispatcherOnUpdateInDEV: Dispatcher).useCacheRefresh = function useCacheRefresh() {
3740 currentHookNameInDev = 'useCacheRefresh';
3741 updateHookTypesDev();
@@ -3964,8 +3922,6 @@ if (__DEV__) {
3922 unstable_isNewReconciler: enableNewReconciler,
3923 };
3924 if (enableCache) {
3967 - (InvalidNestedHooksDispatcherOnRerenderInDEV: Dispatcher).getCacheSignal = getCacheSignal;
3968 - (InvalidNestedHooksDispatcherOnRerenderInDEV: Dispatcher).getCacheForType = getCacheForType;
3925 (InvalidNestedHooksDispatcherOnRerenderInDEV: Dispatcher).useCacheRefresh = function useCacheRefresh() {
3926 currentHookNameInDev = 'useCacheRefresh';
3927 updateHookTypesDev();
packages/react-reconciler/src/ReactFiberHooks.old.js
+1 -45
@@ -26,7 +26,6 @@ import type {
26 import type {Lanes, Lane} from './ReactFiberLane.old';
27 import type {HookFlags} from './ReactHookEffectTags';
28 import type {FiberRoot} from './ReactInternalTypes';
29 -import type {Cache} from './ReactFiberCacheComponent.old';
29 import type {Flags} from './ReactFiberFlags';
30
31 import ReactSharedInternals from 'shared/ReactSharedInternals';
@@ -122,7 +121,7 @@ import {
121 } from './ReactMutableSource.old';
122 import {logStateUpdateScheduled} from './DebugTracing';
123 import {markStateUpdateScheduled} from './ReactFiberDevToolsHook.old';
125 -import {createCache, CacheContext} from './ReactFiberCacheComponent.old';
124 +import {createCache} from './ReactFiberCacheComponent.old';
125 import {
126 createUpdate as createLegacyQueueUpdate,
127 enqueueUpdate as enqueueLegacyQueueUpdate,
@@ -2600,27 +2599,6 @@ function markUpdateInDevTools<A>(fiber, lane, action: A) {
2599 }
2600 }
2601
2603 -function getCacheSignal(): AbortSignal {
2604 - if (!enableCache) {
2605 - throw new Error('Not implemented.');
2606 - }
2607 - const cache: Cache = readContext(CacheContext);
2608 - return cache.controller.signal;
2609 -}
2610 -
2611 -function getCacheForType<T>(resourceType: () => T): T {
2612 - if (!enableCache) {
2613 - throw new Error('Not implemented.');
2614 - }
2615 - const cache: Cache = readContext(CacheContext);
2616 - let cacheForType: T | void = (cache.data.get(resourceType): any);
2617 - if (cacheForType === undefined) {
2618 - cacheForType = resourceType();
2619 - cache.data.set(resourceType, cacheForType);
2620 - }
2621 - return cacheForType;
2622 -}
2623 -
2602 export const ContextOnlyDispatcher: Dispatcher = {
2603 readContext,
2604
@@ -2644,8 +2622,6 @@ export const ContextOnlyDispatcher: Dispatcher = {
2622 unstable_isNewReconciler: enableNewReconciler,
2623 };
2624 if (enableCache) {
2647 - (ContextOnlyDispatcher: Dispatcher).getCacheSignal = getCacheSignal;
2648 - (ContextOnlyDispatcher: Dispatcher).getCacheForType = getCacheForType;
2625 (ContextOnlyDispatcher: Dispatcher).useCacheRefresh = throwInvalidHookError;
2626 }
2627 if (enableUseHook) {
@@ -2681,8 +2657,6 @@ const HooksDispatcherOnMount: Dispatcher = {
2657 unstable_isNewReconciler: enableNewReconciler,
2658 };
2659 if (enableCache) {
2684 - (HooksDispatcherOnMount: Dispatcher).getCacheSignal = getCacheSignal;
2685 - (HooksDispatcherOnMount: Dispatcher).getCacheForType = getCacheForType;
2660 // $FlowFixMe[escaped-generic] discovered when updating Flow
2661 (HooksDispatcherOnMount: Dispatcher).useCacheRefresh = mountRefresh;
2662 }
@@ -2718,8 +2692,6 @@ const HooksDispatcherOnUpdate: Dispatcher = {
2692 unstable_isNewReconciler: enableNewReconciler,
2693 };
2694 if (enableCache) {
2721 - (HooksDispatcherOnUpdate: Dispatcher).getCacheSignal = getCacheSignal;
2722 - (HooksDispatcherOnUpdate: Dispatcher).getCacheForType = getCacheForType;
2695 (HooksDispatcherOnUpdate: Dispatcher).useCacheRefresh = updateRefresh;
2696 }
2697 if (enableUseMemoCacheHook) {
@@ -2755,8 +2727,6 @@ const HooksDispatcherOnRerender: Dispatcher = {
2727 unstable_isNewReconciler: enableNewReconciler,
2728 };
2729 if (enableCache) {
2758 - (HooksDispatcherOnRerender: Dispatcher).getCacheSignal = getCacheSignal;
2759 - (HooksDispatcherOnRerender: Dispatcher).getCacheForType = getCacheForType;
2730 (HooksDispatcherOnRerender: Dispatcher).useCacheRefresh = updateRefresh;
2731 }
2732 if (enableUseHook) {
@@ -2935,8 +2905,6 @@ if (__DEV__) {
2905 unstable_isNewReconciler: enableNewReconciler,
2906 };
2907 if (enableCache) {
2938 - (HooksDispatcherOnMountInDEV: Dispatcher).getCacheSignal = getCacheSignal;
2939 - (HooksDispatcherOnMountInDEV: Dispatcher).getCacheForType = getCacheForType;
2908 (HooksDispatcherOnMountInDEV: Dispatcher).useCacheRefresh = function useCacheRefresh() {
2909 currentHookNameInDev = 'useCacheRefresh';
2910 mountHookTypesDev();
@@ -3094,8 +3062,6 @@ if (__DEV__) {
3062 unstable_isNewReconciler: enableNewReconciler,
3063 };
3064 if (enableCache) {
3097 - (HooksDispatcherOnMountWithHookTypesInDEV: Dispatcher).getCacheSignal = getCacheSignal;
3098 - (HooksDispatcherOnMountWithHookTypesInDEV: Dispatcher).getCacheForType = getCacheForType;
3065 (HooksDispatcherOnMountWithHookTypesInDEV: Dispatcher).useCacheRefresh = function useCacheRefresh() {
3066 currentHookNameInDev = 'useCacheRefresh';
3067 updateHookTypesDev();
@@ -3253,8 +3219,6 @@ if (__DEV__) {
3219 unstable_isNewReconciler: enableNewReconciler,
3220 };
3221 if (enableCache) {
3256 - (HooksDispatcherOnUpdateInDEV: Dispatcher).getCacheSignal = getCacheSignal;
3257 - (HooksDispatcherOnUpdateInDEV: Dispatcher).getCacheForType = getCacheForType;
3222 (HooksDispatcherOnUpdateInDEV: Dispatcher).useCacheRefresh = function useCacheRefresh() {
3223 currentHookNameInDev = 'useCacheRefresh';
3224 updateHookTypesDev();
@@ -3413,8 +3377,6 @@ if (__DEV__) {
3377 unstable_isNewReconciler: enableNewReconciler,
3378 };
3379 if (enableCache) {
3416 - (HooksDispatcherOnRerenderInDEV: Dispatcher).getCacheSignal = getCacheSignal;
3417 - (HooksDispatcherOnRerenderInDEV: Dispatcher).getCacheForType = getCacheForType;
3380 (HooksDispatcherOnRerenderInDEV: Dispatcher).useCacheRefresh = function useCacheRefresh() {
3381 currentHookNameInDev = 'useCacheRefresh';
3382 updateHookTypesDev();
@@ -3589,8 +3551,6 @@ if (__DEV__) {
3551 unstable_isNewReconciler: enableNewReconciler,
3552 };
3553 if (enableCache) {
3592 - (InvalidNestedHooksDispatcherOnMountInDEV: Dispatcher).getCacheSignal = getCacheSignal;
3593 - (InvalidNestedHooksDispatcherOnMountInDEV: Dispatcher).getCacheForType = getCacheForType;
3554 (InvalidNestedHooksDispatcherOnMountInDEV: Dispatcher).useCacheRefresh = function useCacheRefresh() {
3555 currentHookNameInDev = 'useCacheRefresh';
3556 mountHookTypesDev();
@@ -3776,8 +3736,6 @@ if (__DEV__) {
3736 unstable_isNewReconciler: enableNewReconciler,
3737 };
3738 if (enableCache) {
3779 - (InvalidNestedHooksDispatcherOnUpdateInDEV: Dispatcher).getCacheSignal = getCacheSignal;
3780 - (InvalidNestedHooksDispatcherOnUpdateInDEV: Dispatcher).getCacheForType = getCacheForType;
3739 (InvalidNestedHooksDispatcherOnUpdateInDEV: Dispatcher).useCacheRefresh = function useCacheRefresh() {
3740 currentHookNameInDev = 'useCacheRefresh';
3741 updateHookTypesDev();
@@ -3964,8 +3922,6 @@ if (__DEV__) {
3922 unstable_isNewReconciler: enableNewReconciler,
3923 };
3924 if (enableCache) {
3967 - (InvalidNestedHooksDispatcherOnRerenderInDEV: Dispatcher).getCacheSignal = getCacheSignal;
3968 - (InvalidNestedHooksDispatcherOnRerenderInDEV: Dispatcher).getCacheForType = getCacheForType;
3925 (InvalidNestedHooksDispatcherOnRerenderInDEV: Dispatcher).useCacheRefresh = function useCacheRefresh() {
3926 currentHookNameInDev = 'useCacheRefresh';
3927 updateHookTypesDev();
packages/react-reconciler/src/ReactFiberWorkLoop.new.js
+22
@@ -207,6 +207,7 @@ import {
207 ContextOnlyDispatcher,
208 getIsUpdatingOpaqueValueInRenderPhaseInDEV,
209 } from './ReactFiberHooks.new';
210 +import {DefaultCacheDispatcher} from './ReactFiberCache.new';
211 import {
212 createCapturedValueAtFiber,
213 type CapturedValue,
@@ -279,6 +280,7 @@ const PossiblyWeakMap = typeof WeakMap === 'function' ? WeakMap : Map;
280
281 const {
282 ReactCurrentDispatcher,
283 + ReactCurrentCache,
284 ReactCurrentOwner,
285 ReactCurrentBatchConfig,
286 ReactCurrentActQueue,
@@ -1790,6 +1792,22 @@ function popDispatcher(prevDispatcher) {
1792 ReactCurrentDispatcher.current = prevDispatcher;
1793 }
1794
1795 +function pushCacheDispatcher() {
1796 + if (enableCache) {
1797 + const prevCacheDispatcher = ReactCurrentCache.current;
1798 + ReactCurrentCache.current = DefaultCacheDispatcher;
1799 + return prevCacheDispatcher;
1800 + } else {
1801 + return null;
1802 + }
1803 +}
1804 +
1805 +function popCacheDispatcher(prevCacheDispatcher) {
1806 + if (enableCache) {
1807 + ReactCurrentCache.current = prevCacheDispatcher;
1808 + }
1809 +}
1810 +
1811 export function markCommitTimeOfFallback() {
1812 globalMostRecentFallbackTime = now();
1813 }
@@ -1857,6 +1875,7 @@ function renderRootSync(root: FiberRoot, lanes: Lanes) {
1875 const prevExecutionContext = executionContext;
1876 executionContext |= RenderContext;
1877 const prevDispatcher = pushDispatcher(root.containerInfo);
1878 + const prevCacheDispatcher = pushCacheDispatcher();
1879
1880 // If the root or lanes have changed, throw out the existing stack
1881 // and prepare a fresh one. Otherwise we'll continue where we left off.
@@ -1903,6 +1922,7 @@ function renderRootSync(root: FiberRoot, lanes: Lanes) {
1922
1923 executionContext = prevExecutionContext;
1924 popDispatcher(prevDispatcher);
1925 + popCacheDispatcher(prevCacheDispatcher);
1926
1927 if (workInProgress !== null) {
1928 // This is a sync render, so we should have finished the whole tree.
@@ -1957,6 +1977,7 @@ function renderRootConcurrent(root: FiberRoot, lanes: Lanes) {
1977 const prevExecutionContext = executionContext;
1978 executionContext |= RenderContext;
1979 const prevDispatcher = pushDispatcher(root.containerInfo);
1980 + const prevCacheDispatcher = pushCacheDispatcher();
1981
1982 // If the root or lanes have changed, throw out the existing stack
1983 // and prepare a fresh one. Otherwise we'll continue where we left off.
@@ -2009,6 +2030,7 @@ function renderRootConcurrent(root: FiberRoot, lanes: Lanes) {
2030 resetContextDependencies();
2031
2032 popDispatcher(prevDispatcher);
2033 + popCacheDispatcher(prevCacheDispatcher);
2034 executionContext = prevExecutionContext;
2035
2036 if (__DEV__) {
packages/react-reconciler/src/ReactFiberWorkLoop.old.js
+22
@@ -207,6 +207,7 @@ import {
207 ContextOnlyDispatcher,
208 getIsUpdatingOpaqueValueInRenderPhaseInDEV,
209 } from './ReactFiberHooks.old';
210 +import {DefaultCacheDispatcher} from './ReactFiberCache.old';
211 import {
212 createCapturedValueAtFiber,
213 type CapturedValue,
@@ -279,6 +280,7 @@ const PossiblyWeakMap = typeof WeakMap === 'function' ? WeakMap : Map;
280
281 const {
282 ReactCurrentDispatcher,
283 + ReactCurrentCache,
284 ReactCurrentOwner,
285 ReactCurrentBatchConfig,
286 ReactCurrentActQueue,
@@ -1790,6 +1792,22 @@ function popDispatcher(prevDispatcher) {
1792 ReactCurrentDispatcher.current = prevDispatcher;
1793 }
1794
1795 +function pushCacheDispatcher() {
1796 + if (enableCache) {
1797 + const prevCacheDispatcher = ReactCurrentCache.current;
1798 + ReactCurrentCache.current = DefaultCacheDispatcher;
1799 + return prevCacheDispatcher;
1800 + } else {
1801 + return null;
1802 + }
1803 +}
1804 +
1805 +function popCacheDispatcher(prevCacheDispatcher) {
1806 + if (enableCache) {
1807 + ReactCurrentCache.current = prevCacheDispatcher;
1808 + }
1809 +}
1810 +
1811 export function markCommitTimeOfFallback() {
1812 globalMostRecentFallbackTime = now();
1813 }
@@ -1857,6 +1875,7 @@ function renderRootSync(root: FiberRoot, lanes: Lanes) {
1875 const prevExecutionContext = executionContext;
1876 executionContext |= RenderContext;
1877 const prevDispatcher = pushDispatcher(root.containerInfo);
1878 + const prevCacheDispatcher = pushCacheDispatcher();
1879
1880 // If the root or lanes have changed, throw out the existing stack
1881 // and prepare a fresh one. Otherwise we'll continue where we left off.
@@ -1903,6 +1922,7 @@ function renderRootSync(root: FiberRoot, lanes: Lanes) {
1922
1923 executionContext = prevExecutionContext;
1924 popDispatcher(prevDispatcher);
1925 + popCacheDispatcher(prevCacheDispatcher);
1926
1927 if (workInProgress !== null) {
1928 // This is a sync render, so we should have finished the whole tree.
@@ -1957,6 +1977,7 @@ function renderRootConcurrent(root: FiberRoot, lanes: Lanes) {
1977 const prevExecutionContext = executionContext;
1978 executionContext |= RenderContext;
1979 const prevDispatcher = pushDispatcher(root.containerInfo);
1980 + const prevCacheDispatcher = pushCacheDispatcher();
1981
1982 // If the root or lanes have changed, throw out the existing stack
1983 // and prepare a fresh one. Otherwise we'll continue where we left off.
@@ -2009,6 +2030,7 @@ function renderRootConcurrent(root: FiberRoot, lanes: Lanes) {
2030 resetContextDependencies();
2031
2032 popDispatcher(prevDispatcher);
2033 + popCacheDispatcher(prevCacheDispatcher);
2034 executionContext = prevExecutionContext;
2035
2036 if (__DEV__) {
packages/react-reconciler/src/ReactInternalTypes.js
+5 -2
@@ -377,8 +377,6 @@ type Dispatch<A> = A => void;
377
378 export type Dispatcher = {
379 use?: <T>(Usable<T>) => T,
380 - getCacheSignal?: () => AbortSignal,
381 - getCacheForType?: <T>(resourceType: () => T) => T,
380 readContext<T>(context: ReactContext<T>): T,
381 useState<S>(initialState: (() => S) | S): [S, Dispatch<BasicStateAction<S>>],
382 useReducer<S, I, A>(
@@ -432,3 +430,8 @@ export type Dispatcher = {
430
431 unstable_isNewReconciler?: boolean,
432 };
433 +
434 +export type CacheDispatcher = {
435 + getCacheSignal: () => AbortSignal,
436 + getCacheForType: <T>(resourceType: () => T) => T,
437 +};
packages/react-server/src/ReactFizzCache.js new
+23
@@ -0,0 +1,23 @@
1 +/**
2 + * Copyright (c) Facebook, Inc. and its 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 {CacheDispatcher} from 'react-reconciler/src/ReactInternalTypes';
11 +
12 +function getCacheSignal(): AbortSignal {
13 + throw new Error('Not implemented.');
14 +}
15 +
16 +function getCacheForType<T>(resourceType: () => T): T {
17 + throw new Error('Not implemented.');
18 +}
19 +
20 +export const DefaultCacheDispatcher: CacheDispatcher = {
21 + getCacheSignal,
22 + getCacheForType,
23 +};
packages/react-server/src/ReactFizzHooks.js
+6 -13
@@ -8,7 +8,7 @@
8 */
9
10 import type {
11 - Dispatcher as DispatcherType,
11 + Dispatcher,
12 EventFunctionWrapper,
13 } from 'react-reconciler/src/ReactInternalTypes';
14
@@ -274,12 +274,6 @@ export function resetHooksState(): void {
274 workInProgressHook = null;
275 }
276
277 -function getCacheForType<T>(resourceType: () => T): T {
278 - // TODO: This should silently mark this as client rendered since it's not necessarily
279 - // considered an error. It needs to work for things like Flight though.
280 - throw new Error('Not implemented.');
281 -}
282 -
277 function readContext<T>(context: ReactContext<T>): T {
278 if (__DEV__) {
279 if (isInHookUserCodeInDev) {
@@ -677,7 +671,7 @@ function useMemoCache(size: number): Array<any> {
671
672 function noop(): void {}
673
680 -export const Dispatcher: DispatcherType = {
674 +export const HooksDispatcher: Dispatcher = {
675 readContext,
676 useContext,
677 useMemo,
@@ -702,17 +696,16 @@ export const Dispatcher: DispatcherType = {
696 };
697
698 if (enableCache) {
705 - Dispatcher.getCacheForType = getCacheForType;
706 - Dispatcher.useCacheRefresh = useCacheRefresh;
699 + HooksDispatcher.useCacheRefresh = useCacheRefresh;
700 }
701 if (enableUseEventHook) {
709 - Dispatcher.useEvent = useEvent;
702 + HooksDispatcher.useEvent = useEvent;
703 }
704 if (enableUseMemoCacheHook) {
712 - Dispatcher.useMemoCache = useMemoCache;
705 + HooksDispatcher.useMemoCache = useMemoCache;
706 }
707 if (enableUseHook) {
715 - Dispatcher.use = use;
708 + HooksDispatcher.use = use;
709 }
710
711 export let currentResponseState: null | ResponseState = (null: any);
packages/react-server/src/ReactFizzServer.js
+15 -3
@@ -97,11 +97,12 @@ import {
97 finishHooks,
98 checkDidRenderIdHook,
99 resetHooksState,
100 - Dispatcher,
100 + HooksDispatcher,
101 currentResponseState,
102 setCurrentResponseState,
103 getThenableStateAfterSuspending,
104 } from './ReactFizzHooks';
105 +import {DefaultCacheDispatcher} from './ReactFizzCache';
106 import {getStackByComponentStackNode} from './ReactFizzComponentStack';
107 import {emptyTreeContext, pushTreeContext} from './ReactFizzTreeContext';
108
@@ -132,6 +133,7 @@ import {
133 enableScopeAPI,
134 enableSuspenseAvoidThisFallbackFizz,
135 enableFloat,
136 + enableCache,
137 } from 'shared/ReactFeatureFlags';
138
139 import assign from 'shared/assign';
@@ -140,6 +142,7 @@ import isArray from 'shared/isArray';
142 import {trackSuspendedWakeable} from './ReactFizzWakeable';
143
144 const ReactCurrentDispatcher = ReactSharedInternals.ReactCurrentDispatcher;
145 +const ReactCurrentCache = ReactSharedInternals.ReactCurrentCache;
146 const ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame;
147
148 type LegacyContext = {
@@ -1901,7 +1904,13 @@ export function performWork(request: Request): void {
1904 }
1905 const prevContext = getActiveContext();
1906 const prevDispatcher = ReactCurrentDispatcher.current;
1904 - ReactCurrentDispatcher.current = Dispatcher;
1907 + ReactCurrentDispatcher.current = HooksDispatcher;
1908 + let prevCacheDispatcher;
1909 + if (enableCache) {
1910 + prevCacheDispatcher = ReactCurrentCache.current;
1911 + ReactCurrentCache.current = DefaultCacheDispatcher;
1912 + }
1913 +
1914 const previousHostDispatcher = prepareToRender(request.resources);
1915 let prevGetCurrentStackImpl;
1916 if (__DEV__) {
@@ -1927,12 +1936,15 @@ export function performWork(request: Request): void {
1936 } finally {
1937 setCurrentResponseState(prevResponseState);
1938 ReactCurrentDispatcher.current = prevDispatcher;
1939 + if (enableCache) {
1940 + ReactCurrentCache.current = prevCacheDispatcher;
1941 + }
1942 cleanupAfterRender(previousHostDispatcher);
1943
1944 if (__DEV__) {
1945 ReactDebugCurrentFrame.getCurrentStack = prevGetCurrentStackImpl;
1946 }
1935 - if (prevDispatcher === Dispatcher) {
1947 + if (prevDispatcher === HooksDispatcher) {
1948 // This means that we were in a reentrant work loop. This could happen
1949 // in a renderer that supports synchronous work like renderToString,
1950 // when it's called from within another renderer.
packages/react-server/src/ReactFlightCache.js new
+43
@@ -0,0 +1,43 @@
1 +/**
2 + * Copyright (c) Facebook, Inc. and its 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 {CacheDispatcher} from 'react-reconciler/src/ReactInternalTypes';
11 +
12 +export const DefaultCacheDispatcher: CacheDispatcher = {
13 + getCacheSignal(): AbortSignal {
14 + throw new Error('Not implemented.');
15 + },
16 + getCacheForType<T>(resourceType: () => T): T {
17 + if (!currentCache) {
18 + throw new Error('Reading the cache is only supported while rendering.');
19 + }
20 +
21 + let entry: T | void = (currentCache.get(resourceType): any);
22 + if (entry === undefined) {
23 + entry = resourceType();
24 + // TODO: Warn if undefined?
25 + // $FlowFixMe[incompatible-use] found when upgrading Flow
26 + currentCache.set(resourceType, entry);
27 + }
28 + return entry;
29 + },
30 +};
31 +
32 +let currentCache: Map<Function, mixed> | null = null;
33 +
34 +export function setCurrentCache(
35 + cache: Map<Function, mixed> | null,
36 +): Map<Function, mixed> | null {
37 + currentCache = cache;
38 + return currentCache;
39 +}
40 +
41 +export function getCurrentCache(): Map<Function, mixed> | null {
42 + return currentCache;
43 +}
packages/react-server/src/ReactFlightHooks.js
+6 -35
@@ -7,7 +7,7 @@
7 * @flow
8 */
9
10 -import type {Dispatcher as DispatcherType} from 'react-reconciler/src/ReactInternalTypes';
10 +import type {Dispatcher} from 'react-reconciler/src/ReactInternalTypes';
11 import type {Request} from './ReactFlightServer';
12 import type {ReactServerContext, Thenable, Usable} from 'shared/ReactTypes';
13 import type {ThenableState} from './ReactFlightWakeable';
@@ -52,7 +52,7 @@ function readContext<T>(context: ReactServerContext<T>): T {
52 'Only createServerContext is supported in Server Components.',
53 );
54 }
55 - if (currentCache === null) {
55 + if (currentRequest === null) {
56 console.error(
57 'Context can only be read while React is rendering. ' +
58 'In classes, you can read it in the render method or getDerivedStateFromProps. ' +
@@ -64,7 +64,7 @@ function readContext<T>(context: ReactServerContext<T>): T {
64 return readContextImpl(context);
65 }
66
67 -export const Dispatcher: DispatcherType = {
67 +export const HooksDispatcher: Dispatcher = {
68 useMemo<T>(nextCreate: () => T): T {
69 return nextCreate();
70 },
@@ -74,20 +74,6 @@ export const Dispatcher: DispatcherType = {
74 useDebugValue(): void {},
75 useDeferredValue: (unsupportedHook: any),
76 useTransition: (unsupportedHook: any),
77 - getCacheForType<T>(resourceType: () => T): T {
78 - if (!currentCache) {
79 - throw new Error('Reading the cache is only supported while rendering.');
80 - }
81 -
82 - let entry: T | void = (currentCache.get(resourceType): any);
83 - if (entry === undefined) {
84 - entry = resourceType();
85 - // TODO: Warn if undefined?
86 - // $FlowFixMe[incompatible-use] found when upgrading Flow
87 - currentCache.set(resourceType, entry);
88 - }
89 - return entry;
90 - },
77 readContext,
78 useContext: readContext,
79 useReducer: (unsupportedHook: any),
@@ -114,24 +100,9 @@ function unsupportedHook(): void {
100 }
101
102 function unsupportedRefresh(): void {
117 - if (!currentCache) {
118 - throw new Error(
119 - 'Refreshing the cache is not supported in Server Components.',
120 - );
121 - }
122 -}
123 -
124 -let currentCache: Map<Function, mixed> | null = null;
125 -
126 -export function setCurrentCache(
127 - cache: Map<Function, mixed> | null,
128 -): Map<Function, mixed> | null {
129 - currentCache = cache;
130 - return currentCache;
131 -}
132 -
133 -export function getCurrentCache(): Map<Function, mixed> | null {
134 - return currentCache;
103 + throw new Error(
104 + 'Refreshing the cache is not supported in Server Components.',
105 + );
106 }
107
108 function useId(): string {
packages/react-server/src/ReactFlightServer.js
+11 -4
@@ -44,14 +44,17 @@ import {
44 } from './ReactFlightServerConfig';
45
46 import {
47 - Dispatcher,
48 - getCurrentCache,
47 + HooksDispatcher,
48 prepareToUseHooksForRequest,
49 prepareToUseHooksForComponent,
50 getThenableStateAfterSuspending,
51 resetHooksForRequest,
53 - setCurrentCache,
52 } from './ReactFlightHooks';
53 +import {
54 + DefaultCacheDispatcher,
55 + getCurrentCache,
56 + setCurrentCache,
57 +} from './ReactFlightCache';
58 import {
59 pushProvider,
60 popProvider,
@@ -131,6 +134,7 @@ export type Request = {
134 };
135
136 const ReactCurrentDispatcher = ReactSharedInternals.ReactCurrentDispatcher;
137 +const ReactCurrentCache = ReactSharedInternals.ReactCurrentCache;
138
139 function defaultErrorHandler(error: mixed) {
140 console['error'](error);
@@ -1002,8 +1006,10 @@ function retryTask(request: Request, task: Task): void {
1006
1007 function performWork(request: Request): void {
1008 const prevDispatcher = ReactCurrentDispatcher.current;
1009 + const prevCacheDispatcher = ReactCurrentCache.current;
1010 const prevCache = getCurrentCache();
1006 - ReactCurrentDispatcher.current = Dispatcher;
1011 + ReactCurrentDispatcher.current = HooksDispatcher;
1012 + ReactCurrentCache.current = DefaultCacheDispatcher;
1013 setCurrentCache(request.cache);
1014 prepareToUseHooksForRequest(request);
1015
@@ -1022,6 +1028,7 @@ function performWork(request: Request): void {
1028 fatalError(request, error);
1029 } finally {
1030 ReactCurrentDispatcher.current = prevDispatcher;
1031 + ReactCurrentCache.current = prevCacheDispatcher;
1032 setCurrentCache(prevCache);
1033 resetHooksForRequest();
1034 }
packages/react-suspense-test-utils/src/ReactSuspenseTestUtils.js
+7 -25
@@ -7,10 +7,10 @@
7 * @flow
8 */
9
10 -import type {Dispatcher} from 'react-reconciler/src/ReactInternalTypes';
10 +import type {CacheDispatcher} from 'react-reconciler/src/ReactInternalTypes';
11 import ReactSharedInternals from 'shared/ReactSharedInternals';
12
13 -const ReactCurrentDispatcher = ReactSharedInternals.ReactCurrentDispatcher;
13 +const ReactCurrentCache = ReactSharedInternals.ReactCurrentCache;
14
15 function unsupported() {
16 throw new Error('This feature is not supported by ReactSuspenseTestUtils.');
@@ -18,7 +18,8 @@ function unsupported() {
18
19 export function waitForSuspense<T>(fn: () => T): Promise<T> {
20 const cache: Map<Function, mixed> = new Map();
21 - const testDispatcher: Dispatcher = {
21 + const testDispatcher: CacheDispatcher = {
22 + getCacheSignal: unsupported,
23 getCacheForType<R>(resourceType: () => R): R {
24 let entry: R | void = (cache.get(resourceType): any);
25 if (entry === undefined) {
@@ -28,31 +29,12 @@ export function waitForSuspense<T>(fn: () => T): Promise<T> {
29 }
30 return entry;
31 },
31 - readContext: unsupported,
32 - useContext: unsupported,
33 - useMemo: unsupported,
34 - useReducer: unsupported,
35 - useRef: unsupported,
36 - useState: unsupported,
37 - useInsertionEffect: unsupported,
38 - useLayoutEffect: unsupported,
39 - useCallback: unsupported,
40 - useImperativeHandle: unsupported,
41 - useEffect: unsupported,
42 - useDebugValue: unsupported,
43 - useDeferredValue: unsupported,
44 - useTransition: unsupported,
45 - useId: unsupported,
46 - useMutableSource: unsupported,
47 - useSyncExternalStore: unsupported,
48 - useCacheRefresh: unsupported,
49 - useMemoCache: unsupported,
32 };
33 // Not using async/await because we don't compile it.
34 return new Promise((resolve, reject) => {
35 function retry() {
54 - const prevDispatcher = ReactCurrentDispatcher.current;
55 - ReactCurrentDispatcher.current = testDispatcher;
36 + const prevDispatcher = ReactCurrentCache.current;
37 + ReactCurrentCache.current = testDispatcher;
38 try {
39 const result = fn();
40 resolve(result);
@@ -63,7 +45,7 @@ export function waitForSuspense<T>(fn: () => T): Promise<T> {
45 reject(thrownValue);
46 }
47 } finally {
66 - ReactCurrentDispatcher.current = prevDispatcher;
48 + ReactCurrentCache.current = prevDispatcher;
49 }
50 }
51 retry();
packages/react/src/ReactCurrentCache.js new
+19
@@ -0,0 +1,19 @@
1 +/**
2 + * Copyright (c) Facebook, Inc. and its 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 {CacheDispatcher} from 'react-reconciler/src/ReactInternalTypes';
11 +
12 +/**
13 + * Keeps track of the current Cache dispatcher.
14 + */
15 +const ReactCurrentCache = {
16 + current: (null: null | CacheDispatcher),
17 +};
18 +
19 +export default ReactCurrentCache;
packages/react/src/ReactCurrentDispatcher.js
-4
@@ -13,10 +13,6 @@ import type {Dispatcher} from 'react-reconciler/src/ReactInternalTypes';
13 * Keeps track of the current dispatcher.
14 */
15 const ReactCurrentDispatcher = {
16 - /**
17 - * @internal
18 - * @type {ReactComponent}
19 - */
16 current: (null: null | Dispatcher),
17 };
18
packages/react/src/ReactHooks.js
+23 -4
@@ -18,6 +18,7 @@ import type {
18 } from 'shared/ReactTypes';
19
20 import ReactCurrentDispatcher from './ReactCurrentDispatcher';
21 +import ReactCurrentCache from './ReactCurrentCache';
22
23 type BasicStateAction<S> = (S => S) | S;
24 type Dispatch<A> = A => void;
@@ -43,14 +44,32 @@ function resolveDispatcher() {
44 }
45
46 export function getCacheSignal(): AbortSignal {
46 - const dispatcher = resolveDispatcher();
47 - // $FlowFixMe This is unstable, thus optional
47 + const dispatcher = ReactCurrentCache.current;
48 + if (!dispatcher) {
49 + // If we have no cache to associate with this call, then we don't know
50 + // its lifetime. We abort early since that's safer than letting it live
51 + // for ever. Unlike just caching which can be a functional noop outside
52 + // of React, these should generally always be associated with some React
53 + // render but we're not limiting quite as much as making it a Hook.
54 + // It's safer than erroring early at runtime.
55 + const controller = new AbortController();
56 + const reason = new Error(
57 + 'This CacheSignal was requested outside React which means that it is ' +
58 + 'immediately aborted.',
59 + );
60 + // $FlowFixMe Flow doesn't yet know about this argument.
61 + controller.abort(reason);
62 + return controller.signal;
63 + }
64 return dispatcher.getCacheSignal();
65 }
66
67 export function getCacheForType<T>(resourceType: () => T): T {
52 - const dispatcher = resolveDispatcher();
53 - // $FlowFixMe This is unstable, thus optional
68 + const dispatcher = ReactCurrentCache.current;
69 + if (!dispatcher) {
70 + // If there is no dispatcher, then we treat this as not being cached.
71 + return resourceType();
72 + }
73 return dispatcher.getCacheForType(resourceType);
74 }
75
packages/react/src/ReactSharedInternals.js
+2
@@ -6,6 +6,7 @@
6 */
7
8 import ReactCurrentDispatcher from './ReactCurrentDispatcher';
9 +import ReactCurrentCache from './ReactCurrentCache';
10 import ReactCurrentBatchConfig from './ReactCurrentBatchConfig';
11 import ReactCurrentActQueue from './ReactCurrentActQueue';
12 import ReactCurrentOwner from './ReactCurrentOwner';
@@ -15,6 +16,7 @@ import {ContextRegistry} from './ReactServerContextRegistry';
16
17 const ReactSharedInternals = {
18 ReactCurrentDispatcher,
19 + ReactCurrentCache,
20 ReactCurrentBatchConfig,
21 ReactCurrentOwner,
22 };
packages/react/src/forks/ReactCurrentDispatcher.www.js deleted
-8
@@ -1,8 +0,0 @@
1 -/**
2 - * Copyright (c) Facebook, Inc. and its 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 -
8 -export default require('ReactCurrentDispatcher');
packages/react/src/forks/ReactCurrentOwner.www.js deleted
-8
@@ -1,8 +0,0 @@
1 -/**
2 - * Copyright (c) Facebook, Inc. and its 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 -
8 -export default require('ReactCurrentOwner');
packages/react/src/forks/ReactSharedInternals.umd.js
+2
@@ -7,6 +7,7 @@
7
8 import * as Scheduler from 'scheduler';
9 import ReactCurrentDispatcher from '../ReactCurrentDispatcher';
10 +import ReactCurrentCache from '../ReactCurrentCache';
11 import ReactCurrentActQueue from '../ReactCurrentActQueue';
12 import ReactCurrentOwner from '../ReactCurrentOwner';
13 import ReactDebugCurrentFrame from '../ReactDebugCurrentFrame';
@@ -16,6 +17,7 @@ import {ContextRegistry} from '../ReactServerContextRegistry';
17
18 const ReactSharedInternals = {
19 ReactCurrentDispatcher,
20 + ReactCurrentCache,
21 ReactCurrentOwner,
22 ReactCurrentBatchConfig,
23
scripts/error-codes/codes.json
+3 -2
@@ -439,5 +439,6 @@
439 "451": "resolveSingletonInstance was called with an element type that is not supported. This is a bug in React.",
440 "452": "React expected an <html> element (document.documentElement) to exist in the Document but one was not found. React never removes the documentElement for any Document it renders into so the cause is likely in some other script running on this page.",
441 "453": "React expected a <head> element (document.head) to exist in the Document but one was not found. React never removes the head for any Document it renders into so the cause is likely in some other script running on this page.",
442 - "454": "React expected a <body> element (document.body) to exist in the Document but one was not found. React never removes the body for any Document it renders into so the cause is likely in some other script running on this page."
443 -}
442 + "454": "React expected a <body> element (document.body) to exist in the Document but one was not found. React never removes the body for any Document it renders into so the cause is likely in some other script running on this page.",
443 + "455": "This CacheSignal was requested outside React which means that it is immediately aborted."
444 +}
\ No newline at end of file
scripts/rollup/forks.js
-26
@@ -208,32 +208,6 @@ const forks = Object.freeze({
208 }
209 },
210
211 - // In FB bundles, we preserve an inline require to ReactCurrentOwner.
212 - // See the explanation in FB version of ReactCurrentOwner in www:
213 - './packages/react/src/ReactCurrentOwner.js': (bundleType, entry) => {
214 - switch (bundleType) {
215 - case FB_WWW_DEV:
216 - case FB_WWW_PROD:
217 - case FB_WWW_PROFILING:
218 - return './packages/react/src/forks/ReactCurrentOwner.www.js';
219 - default:
220 - return null;
221 - }
222 - },
223 -
224 - // Similarly, we preserve an inline require to ReactCurrentDispatcher.
225 - // See the explanation in FB version of ReactCurrentDispatcher in www:
226 - './packages/react/src/ReactCurrentDispatcher.js': (bundleType, entry) => {
227 - switch (bundleType) {
228 - case FB_WWW_DEV:
229 - case FB_WWW_PROD:
230 - case FB_WWW_PROFILING:
231 - return './packages/react/src/forks/ReactCurrentDispatcher.www.js';
232 - default:
233 - return null;
234 - }
235 - },
236 -
211 './packages/react/src/ReactSharedInternals.js': (bundleType, entry) => {
212 switch (bundleType) {
213 case UMD_DEV: