File tree Expand file tree Collapse file tree 8 files changed +15
-12
lines changed Expand file tree Collapse file tree 8 files changed +15
-12
lines changed Original file line number Diff line number Diff line change 99
1010import type { Wakeable } from 'shared/ReactTypes' ;
1111
12- import * as React from 'react' ;
12+ import { unstable_getCacheForType } from 'react' ;
1313
1414const Pending = 0 ;
1515const Resolved = 1 ;
@@ -35,12 +35,8 @@ type Result = PendingResult | ResolvedResult | RejectedResult;
3535// TODO: this is a browser-only version. Add a separate Node entry point.
3636const nativeFetch = window . fetch ;
3737
38- const ReactCurrentDispatcher =
39- React . __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED
40- . ReactCurrentDispatcher ;
41-
4238function getResultMap ( ) : Map < string , Result > {
43- return ReactCurrentDispatcher . current . getCacheForType ( createResultMap ) ;
39+ return unstable_getCacheForType ( createResultMap ) ;
4440}
4541
4642function createResultMap ( ) : Map < string , Result > {
Original file line number Diff line number Diff line change @@ -11,7 +11,7 @@ import type {Wakeable} from 'shared/ReactTypes';
1111
1212import * as http from 'http' ;
1313import * as https from 'https' ;
14- import * as React from 'react' ;
14+ import { unstable_getCacheForType } from 'react' ;
1515
1616type FetchResponse = { |
1717 // Properties
@@ -74,12 +74,8 @@ type RejectedResult = {|
7474
7575type Result < V > = PendingResult | ResolvedResult < V > | RejectedResult ;
7676
77- const ReactCurrentDispatcher =
78- React . __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED
79- . ReactCurrentDispatcher ;
80-
8177function getResultMap ( ) : Map < string , Result < FetchResponse >> {
82- return ReactCurrentDispatcher . current . getCacheForType ( createResultMap ) ;
78+ return unstable_getCacheForType ( createResultMap ) ;
8379}
8480
8581function createResultMap ( ) : Map < string , Result < FetchResponse >> {
Original file line number Diff line number Diff line change @@ -50,6 +50,7 @@ export {
5050 startTransition as unstable_startTransition ,
5151 SuspenseList ,
5252 SuspenseList as unstable_SuspenseList ,
53+ unstable_getCacheForType ,
5354 // enableScopeAPI
5455 unstable_Scope ,
5556 unstable_useOpaqueIdentifier ,
Original file line number Diff line number Diff line change @@ -45,6 +45,7 @@ export {
4545 startTransition as unstable_startTransition ,
4646 SuspenseList as unstable_SuspenseList ,
4747 unstable_useOpaqueIdentifier ,
48+ unstable_getCacheForType ,
4849 // enableDebugTracing
4950 unstable_DebugTracingMode ,
5051} from './src/React' ;
Original file line number Diff line number Diff line change @@ -82,4 +82,5 @@ export {
8282 unstable_createFundamental ,
8383 unstable_Scope ,
8484 unstable_useOpaqueIdentifier ,
85+ unstable_getCacheForType ,
8586} from './src/React' ;
Original file line number Diff line number Diff line change @@ -49,6 +49,7 @@ export {
4949 startTransition as unstable_startTransition ,
5050 SuspenseList ,
5151 SuspenseList as unstable_SuspenseList ,
52+ unstable_getCacheForType ,
5253 // enableScopeAPI
5354 unstable_Scope ,
5455 unstable_useOpaqueIdentifier ,
Original file line number Diff line number Diff line change @@ -33,6 +33,7 @@ import {lazy} from './ReactLazy';
3333import { forwardRef } from './ReactForwardRef' ;
3434import { memo } from './ReactMemo' ;
3535import {
36+ getCacheForType ,
3637 useCallback ,
3738 useContext ,
3839 useEffect ,
@@ -110,6 +111,7 @@ export {
110111 useDeferredValue ,
111112 REACT_SUSPENSE_LIST_TYPE as SuspenseList ,
112113 REACT_LEGACY_HIDDEN_TYPE as unstable_LegacyHidden ,
114+ getCacheForType as unstable_getCacheForType ,
113115 // enableFundamentalAPI
114116 createFundamental as unstable_createFundamental ,
115117 // enableScopeAPI
Original file line number Diff line number Diff line change @@ -36,6 +36,11 @@ function resolveDispatcher() {
3636 return dispatcher ;
3737}
3838
39+ export function getCacheForType < T > ( resourceType : ( ) = > T ) : T {
40+ const dispatcher = resolveDispatcher ( ) ;
41+ return dispatcher . getCacheForType ( resourceType ) ;
42+ }
43+
3944export function useContext < T > (
4045 Context : ReactContext < T > ,
4146 unstable_observedBits : number | boolean | void ,
You can’t perform that action at this time.
0 commit comments