@samitouri / QOS-React-2 / commits / 74394aa8cb

Add unstable_isNewReconciler to dispatcher (#18975)

This is a bit gross but I need to be able to access it without importing the renderer. There might be a better way but I need this to unblock internal bugfix.

Andrew Clark committed May 21, 2020 at 11:56 UTC 74394aa8cbb7a1c18c34018b099a9b5ab10ef11c
3 files changed +51 -1
packages/react-reconciler/src/ReactFiberHooks.new.js
+23
@@ -24,6 +24,7 @@ import type {FiberRoot} from './ReactInternalTypes';
24 import type {OpaqueIDType} from './ReactFiberHostConfig';
25
26 import ReactSharedInternals from 'shared/ReactSharedInternals';
27 +import {enableNewReconciler} from 'shared/ReactFeatureFlags';
28
29 import {NoMode, BlockingMode} from './ReactTypeOfMode';
30 import {
@@ -1738,6 +1739,8 @@ export const ContextOnlyDispatcher: Dispatcher = {
1739 useTransition: throwInvalidHookError,
1740 useMutableSource: throwInvalidHookError,
1741 useOpaqueIdentifier: throwInvalidHookError,
1742 +
1743 + unstable_isNewReconciler: enableNewReconciler,
1744 };
1745
1746 const HooksDispatcherOnMount: Dispatcher = {
@@ -1758,6 +1761,8 @@ const HooksDispatcherOnMount: Dispatcher = {
1761 useTransition: mountTransition,
1762 useMutableSource: mountMutableSource,
1763 useOpaqueIdentifier: mountOpaqueIdentifier,
1764 +
1765 + unstable_isNewReconciler: enableNewReconciler,
1766 };
1767
1768 const HooksDispatcherOnUpdate: Dispatcher = {
@@ -1778,6 +1783,8 @@ const HooksDispatcherOnUpdate: Dispatcher = {
1783 useTransition: updateTransition,
1784 useMutableSource: updateMutableSource,
1785 useOpaqueIdentifier: updateOpaqueIdentifier,
1786 +
1787 + unstable_isNewReconciler: enableNewReconciler,
1788 };
1789
1790 const HooksDispatcherOnRerender: Dispatcher = {
@@ -1798,6 +1805,8 @@ const HooksDispatcherOnRerender: Dispatcher = {
1805 useTransition: rerenderTransition,
1806 useMutableSource: updateMutableSource,
1807 useOpaqueIdentifier: rerenderOpaqueIdentifier,
1808 +
1809 + unstable_isNewReconciler: enableNewReconciler,
1810 };
1811
1812 let HooksDispatcherOnMountInDEV: Dispatcher | null = null;
@@ -1960,6 +1969,8 @@ if (__DEV__) {
1969 mountHookTypesDev();
1970 return mountOpaqueIdentifier();
1971 },
1972 +
1973 + unstable_isNewReconciler: enableNewReconciler,
1974 };
1975
1976 HooksDispatcherOnMountWithHookTypesInDEV = {
@@ -2090,6 +2101,8 @@ if (__DEV__) {
2101 updateHookTypesDev();
2102 return mountOpaqueIdentifier();
2103 },
2104 +
2105 + unstable_isNewReconciler: enableNewReconciler,
2106 };
2107
2108 HooksDispatcherOnUpdateInDEV = {
@@ -2220,6 +2233,8 @@ if (__DEV__) {
2233 updateHookTypesDev();
2234 return updateOpaqueIdentifier();
2235 },
2236 +
2237 + unstable_isNewReconciler: enableNewReconciler,
2238 };
2239
2240 HooksDispatcherOnRerenderInDEV = {
@@ -2351,6 +2366,8 @@ if (__DEV__) {
2366 updateHookTypesDev();
2367 return rerenderOpaqueIdentifier();
2368 },
2369 +
2370 + unstable_isNewReconciler: enableNewReconciler,
2371 };
2372
2373 InvalidNestedHooksDispatcherOnMountInDEV = {
@@ -2497,6 +2514,8 @@ if (__DEV__) {
2514 mountHookTypesDev();
2515 return mountOpaqueIdentifier();
2516 },
2517 +
2518 + unstable_isNewReconciler: enableNewReconciler,
2519 };
2520
2521 InvalidNestedHooksDispatcherOnUpdateInDEV = {
@@ -2643,6 +2662,8 @@ if (__DEV__) {
2662 updateHookTypesDev();
2663 return updateOpaqueIdentifier();
2664 },
2665 +
2666 + unstable_isNewReconciler: enableNewReconciler,
2667 };
2668
2669 InvalidNestedHooksDispatcherOnRerenderInDEV = {
@@ -2790,5 +2811,7 @@ if (__DEV__) {
2811 updateHookTypesDev();
2812 return rerenderOpaqueIdentifier();
2813 },
2814 +
2815 + unstable_isNewReconciler: enableNewReconciler,
2816 };
2817 }
packages/react-reconciler/src/ReactFiberHooks.old.js
+26 -1
@@ -24,7 +24,10 @@ import type {FiberRoot} from './ReactInternalTypes';
24 import type {OpaqueIDType} from './ReactFiberHostConfig';
25
26 import ReactSharedInternals from 'shared/ReactSharedInternals';
27 -import {enableDebugTracing} from 'shared/ReactFeatureFlags';
27 +import {
28 + enableDebugTracing,
29 + enableNewReconciler,
30 +} from 'shared/ReactFeatureFlags';
31
32 import {markRootExpiredAtTime} from './ReactFiberRoot.old';
33 import {NoMode, BlockingMode, DebugTracingMode} from './ReactTypeOfMode';
@@ -1757,6 +1760,8 @@ export const ContextOnlyDispatcher: Dispatcher = {
1760 useTransition: throwInvalidHookError,
1761 useMutableSource: throwInvalidHookError,
1762 useOpaqueIdentifier: throwInvalidHookError,
1763 +
1764 + unstable_isNewReconciler: enableNewReconciler,
1765 };
1766
1767 const HooksDispatcherOnMount: Dispatcher = {
@@ -1777,6 +1782,8 @@ const HooksDispatcherOnMount: Dispatcher = {
1782 useTransition: mountTransition,
1783 useMutableSource: mountMutableSource,
1784 useOpaqueIdentifier: mountOpaqueIdentifier,
1785 +
1786 + unstable_isNewReconciler: enableNewReconciler,
1787 };
1788
1789 const HooksDispatcherOnUpdate: Dispatcher = {
@@ -1797,6 +1804,8 @@ const HooksDispatcherOnUpdate: Dispatcher = {
1804 useTransition: updateTransition,
1805 useMutableSource: updateMutableSource,
1806 useOpaqueIdentifier: updateOpaqueIdentifier,
1807 +
1808 + unstable_isNewReconciler: enableNewReconciler,
1809 };
1810
1811 const HooksDispatcherOnRerender: Dispatcher = {
@@ -1817,6 +1826,8 @@ const HooksDispatcherOnRerender: Dispatcher = {
1826 useTransition: rerenderTransition,
1827 useMutableSource: updateMutableSource,
1828 useOpaqueIdentifier: rerenderOpaqueIdentifier,
1829 +
1830 + unstable_isNewReconciler: enableNewReconciler,
1831 };
1832
1833 let HooksDispatcherOnMountInDEV: Dispatcher | null = null;
@@ -1979,6 +1990,8 @@ if (__DEV__) {
1990 mountHookTypesDev();
1991 return mountOpaqueIdentifier();
1992 },
1993 +
1994 + unstable_isNewReconciler: enableNewReconciler,
1995 };
1996
1997 HooksDispatcherOnMountWithHookTypesInDEV = {
@@ -2109,6 +2122,8 @@ if (__DEV__) {
2122 updateHookTypesDev();
2123 return mountOpaqueIdentifier();
2124 },
2125 +
2126 + unstable_isNewReconciler: enableNewReconciler,
2127 };
2128
2129 HooksDispatcherOnUpdateInDEV = {
@@ -2239,6 +2254,8 @@ if (__DEV__) {
2254 updateHookTypesDev();
2255 return updateOpaqueIdentifier();
2256 },
2257 +
2258 + unstable_isNewReconciler: enableNewReconciler,
2259 };
2260
2261 HooksDispatcherOnRerenderInDEV = {
@@ -2370,6 +2387,8 @@ if (__DEV__) {
2387 updateHookTypesDev();
2388 return rerenderOpaqueIdentifier();
2389 },
2390 +
2391 + unstable_isNewReconciler: enableNewReconciler,
2392 };
2393
2394 InvalidNestedHooksDispatcherOnMountInDEV = {
@@ -2516,6 +2535,8 @@ if (__DEV__) {
2535 mountHookTypesDev();
2536 return mountOpaqueIdentifier();
2537 },
2538 +
2539 + unstable_isNewReconciler: enableNewReconciler,
2540 };
2541
2542 InvalidNestedHooksDispatcherOnUpdateInDEV = {
@@ -2662,6 +2683,8 @@ if (__DEV__) {
2683 updateHookTypesDev();
2684 return updateOpaqueIdentifier();
2685 },
2686 +
2687 + unstable_isNewReconciler: enableNewReconciler,
2688 };
2689
2690 InvalidNestedHooksDispatcherOnRerenderInDEV = {
@@ -2809,5 +2832,7 @@ if (__DEV__) {
2832 updateHookTypesDev();
2833 return rerenderOpaqueIdentifier();
2834 },
2835 +
2836 + unstable_isNewReconciler: enableNewReconciler,
2837 };
2838 }
packages/react-reconciler/src/ReactInternalTypes.js
+2
@@ -350,4 +350,6 @@ export type Dispatcher = {|
350 subscribe: MutableSourceSubscribeFn<Source, Snapshot>,
351 ): Snapshot,
352 useOpaqueIdentifier(): any,
353 +
354 + unstable_isNewReconciler?: boolean,
355 |};