File tree Expand file tree Collapse file tree 8 files changed +18
-12
lines changed Expand file tree Collapse file tree 8 files changed +18
-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 { 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 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 { 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 getCacheForType ( createResultMap ) ;
8379}
8480
8581function createResultMap ( ) : Map < string , Result < FetchResponse >> {
Original file line number Diff line number Diff line change @@ -42,6 +42,8 @@ export {
4242 __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED ,
4343 createFactory ,
4444 // exposeConcurrentModeAPIs
45+ getCacheForType ,
46+ getCacheForType as unstable_getCacheForType ,
4547 useTransition ,
4648 useTransition as unstable_useTransition ,
4749 useDeferredValue ,
Original file line number Diff line number Diff line change @@ -40,6 +40,7 @@ export {
4040 __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED ,
4141 createFactory ,
4242 // exposeConcurrentModeAPIs
43+ getCacheForType as unstable_getCacheForType ,
4344 useTransition as unstable_useTransition ,
4445 useDeferredValue as unstable_useDeferredValue ,
4546 startTransition as unstable_startTransition ,
Original file line number Diff line number Diff line change @@ -70,6 +70,8 @@ export {
7070 version ,
7171 __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED ,
7272 createFactory ,
73+ getCacheForType ,
74+ getCacheForType as unstable_getCacheForType ,
7375 useTransition ,
7476 useTransition as unstable_useTransition ,
7577 startTransition ,
Original file line number Diff line number Diff line change @@ -41,6 +41,8 @@ export {
4141 version ,
4242 __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED ,
4343 // exposeConcurrentModeAPIs
44+ getCacheForType ,
45+ getCacheForType as unstable_getCacheForType ,
4446 useTransition ,
4547 useTransition as unstable_useTransition ,
4648 useDeferredValue ,
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 ,
@@ -105,6 +106,7 @@ export {
105106 // Deprecated behind disableCreateFactory
106107 createFactory ,
107108 // Concurrent Mode
109+ getCacheForType ,
108110 useTransition ,
109111 startTransition ,
110112 useDeferredValue ,
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