Skip to content

Commit 74394aa

Browse files
authored
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.
1 parent 099f737 commit 74394aa

3 files changed

Lines changed: 51 additions & 1 deletion

File tree

packages/react-reconciler/src/ReactFiberHooks.new.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import type {FiberRoot} from './ReactInternalTypes';
2424
import type {OpaqueIDType} from './ReactFiberHostConfig';
2525

2626
import ReactSharedInternals from 'shared/ReactSharedInternals';
27+
import {enableNewReconciler} from 'shared/ReactFeatureFlags';
2728

2829
import {NoMode, BlockingMode} from './ReactTypeOfMode';
2930
import {
@@ -1738,6 +1739,8 @@ export const ContextOnlyDispatcher: Dispatcher = {
17381739
useTransition: throwInvalidHookError,
17391740
useMutableSource: throwInvalidHookError,
17401741
useOpaqueIdentifier: throwInvalidHookError,
1742+
1743+
unstable_isNewReconciler: enableNewReconciler,
17411744
};
17421745

17431746
const HooksDispatcherOnMount: Dispatcher = {
@@ -1758,6 +1761,8 @@ const HooksDispatcherOnMount: Dispatcher = {
17581761
useTransition: mountTransition,
17591762
useMutableSource: mountMutableSource,
17601763
useOpaqueIdentifier: mountOpaqueIdentifier,
1764+
1765+
unstable_isNewReconciler: enableNewReconciler,
17611766
};
17621767

17631768
const HooksDispatcherOnUpdate: Dispatcher = {
@@ -1778,6 +1783,8 @@ const HooksDispatcherOnUpdate: Dispatcher = {
17781783
useTransition: updateTransition,
17791784
useMutableSource: updateMutableSource,
17801785
useOpaqueIdentifier: updateOpaqueIdentifier,
1786+
1787+
unstable_isNewReconciler: enableNewReconciler,
17811788
};
17821789

17831790
const HooksDispatcherOnRerender: Dispatcher = {
@@ -1798,6 +1805,8 @@ const HooksDispatcherOnRerender: Dispatcher = {
17981805
useTransition: rerenderTransition,
17991806
useMutableSource: updateMutableSource,
18001807
useOpaqueIdentifier: rerenderOpaqueIdentifier,
1808+
1809+
unstable_isNewReconciler: enableNewReconciler,
18011810
};
18021811

18031812
let HooksDispatcherOnMountInDEV: Dispatcher | null = null;
@@ -1960,6 +1969,8 @@ if (__DEV__) {
19601969
mountHookTypesDev();
19611970
return mountOpaqueIdentifier();
19621971
},
1972+
1973+
unstable_isNewReconciler: enableNewReconciler,
19631974
};
19641975

19651976
HooksDispatcherOnMountWithHookTypesInDEV = {
@@ -2090,6 +2101,8 @@ if (__DEV__) {
20902101
updateHookTypesDev();
20912102
return mountOpaqueIdentifier();
20922103
},
2104+
2105+
unstable_isNewReconciler: enableNewReconciler,
20932106
};
20942107

20952108
HooksDispatcherOnUpdateInDEV = {
@@ -2220,6 +2233,8 @@ if (__DEV__) {
22202233
updateHookTypesDev();
22212234
return updateOpaqueIdentifier();
22222235
},
2236+
2237+
unstable_isNewReconciler: enableNewReconciler,
22232238
};
22242239

22252240
HooksDispatcherOnRerenderInDEV = {
@@ -2351,6 +2366,8 @@ if (__DEV__) {
23512366
updateHookTypesDev();
23522367
return rerenderOpaqueIdentifier();
23532368
},
2369+
2370+
unstable_isNewReconciler: enableNewReconciler,
23542371
};
23552372

23562373
InvalidNestedHooksDispatcherOnMountInDEV = {
@@ -2497,6 +2514,8 @@ if (__DEV__) {
24972514
mountHookTypesDev();
24982515
return mountOpaqueIdentifier();
24992516
},
2517+
2518+
unstable_isNewReconciler: enableNewReconciler,
25002519
};
25012520

25022521
InvalidNestedHooksDispatcherOnUpdateInDEV = {
@@ -2643,6 +2662,8 @@ if (__DEV__) {
26432662
updateHookTypesDev();
26442663
return updateOpaqueIdentifier();
26452664
},
2665+
2666+
unstable_isNewReconciler: enableNewReconciler,
26462667
};
26472668

26482669
InvalidNestedHooksDispatcherOnRerenderInDEV = {
@@ -2790,5 +2811,7 @@ if (__DEV__) {
27902811
updateHookTypesDev();
27912812
return rerenderOpaqueIdentifier();
27922813
},
2814+
2815+
unstable_isNewReconciler: enableNewReconciler,
27932816
};
27942817
}

packages/react-reconciler/src/ReactFiberHooks.old.js

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,10 @@ import type {FiberRoot} from './ReactInternalTypes';
2424
import type {OpaqueIDType} from './ReactFiberHostConfig';
2525

2626
import ReactSharedInternals from 'shared/ReactSharedInternals';
27-
import {enableDebugTracing} from 'shared/ReactFeatureFlags';
27+
import {
28+
enableDebugTracing,
29+
enableNewReconciler,
30+
} from 'shared/ReactFeatureFlags';
2831

2932
import {markRootExpiredAtTime} from './ReactFiberRoot.old';
3033
import {NoMode, BlockingMode, DebugTracingMode} from './ReactTypeOfMode';
@@ -1757,6 +1760,8 @@ export const ContextOnlyDispatcher: Dispatcher = {
17571760
useTransition: throwInvalidHookError,
17581761
useMutableSource: throwInvalidHookError,
17591762
useOpaqueIdentifier: throwInvalidHookError,
1763+
1764+
unstable_isNewReconciler: enableNewReconciler,
17601765
};
17611766

17621767
const HooksDispatcherOnMount: Dispatcher = {
@@ -1777,6 +1782,8 @@ const HooksDispatcherOnMount: Dispatcher = {
17771782
useTransition: mountTransition,
17781783
useMutableSource: mountMutableSource,
17791784
useOpaqueIdentifier: mountOpaqueIdentifier,
1785+
1786+
unstable_isNewReconciler: enableNewReconciler,
17801787
};
17811788

17821789
const HooksDispatcherOnUpdate: Dispatcher = {
@@ -1797,6 +1804,8 @@ const HooksDispatcherOnUpdate: Dispatcher = {
17971804
useTransition: updateTransition,
17981805
useMutableSource: updateMutableSource,
17991806
useOpaqueIdentifier: updateOpaqueIdentifier,
1807+
1808+
unstable_isNewReconciler: enableNewReconciler,
18001809
};
18011810

18021811
const HooksDispatcherOnRerender: Dispatcher = {
@@ -1817,6 +1826,8 @@ const HooksDispatcherOnRerender: Dispatcher = {
18171826
useTransition: rerenderTransition,
18181827
useMutableSource: updateMutableSource,
18191828
useOpaqueIdentifier: rerenderOpaqueIdentifier,
1829+
1830+
unstable_isNewReconciler: enableNewReconciler,
18201831
};
18211832

18221833
let HooksDispatcherOnMountInDEV: Dispatcher | null = null;
@@ -1979,6 +1990,8 @@ if (__DEV__) {
19791990
mountHookTypesDev();
19801991
return mountOpaqueIdentifier();
19811992
},
1993+
1994+
unstable_isNewReconciler: enableNewReconciler,
19821995
};
19831996

19841997
HooksDispatcherOnMountWithHookTypesInDEV = {
@@ -2109,6 +2122,8 @@ if (__DEV__) {
21092122
updateHookTypesDev();
21102123
return mountOpaqueIdentifier();
21112124
},
2125+
2126+
unstable_isNewReconciler: enableNewReconciler,
21122127
};
21132128

21142129
HooksDispatcherOnUpdateInDEV = {
@@ -2239,6 +2254,8 @@ if (__DEV__) {
22392254
updateHookTypesDev();
22402255
return updateOpaqueIdentifier();
22412256
},
2257+
2258+
unstable_isNewReconciler: enableNewReconciler,
22422259
};
22432260

22442261
HooksDispatcherOnRerenderInDEV = {
@@ -2370,6 +2387,8 @@ if (__DEV__) {
23702387
updateHookTypesDev();
23712388
return rerenderOpaqueIdentifier();
23722389
},
2390+
2391+
unstable_isNewReconciler: enableNewReconciler,
23732392
};
23742393

23752394
InvalidNestedHooksDispatcherOnMountInDEV = {
@@ -2516,6 +2535,8 @@ if (__DEV__) {
25162535
mountHookTypesDev();
25172536
return mountOpaqueIdentifier();
25182537
},
2538+
2539+
unstable_isNewReconciler: enableNewReconciler,
25192540
};
25202541

25212542
InvalidNestedHooksDispatcherOnUpdateInDEV = {
@@ -2662,6 +2683,8 @@ if (__DEV__) {
26622683
updateHookTypesDev();
26632684
return updateOpaqueIdentifier();
26642685
},
2686+
2687+
unstable_isNewReconciler: enableNewReconciler,
26652688
};
26662689

26672690
InvalidNestedHooksDispatcherOnRerenderInDEV = {
@@ -2809,5 +2832,7 @@ if (__DEV__) {
28092832
updateHookTypesDev();
28102833
return rerenderOpaqueIdentifier();
28112834
},
2835+
2836+
unstable_isNewReconciler: enableNewReconciler,
28122837
};
28132838
}

packages/react-reconciler/src/ReactInternalTypes.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,4 +350,6 @@ export type Dispatcher = {|
350350
subscribe: MutableSourceSubscribeFn<Source, Snapshot>,
351351
): Snapshot,
352352
useOpaqueIdentifier(): any,
353+
354+
unstable_isNewReconciler?: boolean,
353355
|};

0 commit comments

Comments
 (0)