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 9
9
10
10
import type { Wakeable } from 'shared/ReactTypes' ;
11
11
12
- import * as React from 'react' ;
12
+ import { getCacheForType } from 'react' ;
13
13
14
14
const Pending = 0 ;
15
15
const Resolved = 1 ;
@@ -35,12 +35,8 @@ type Result = PendingResult | ResolvedResult | RejectedResult;
35
35
// TODO: this is a browser-only version. Add a separate Node entry point.
36
36
const nativeFetch = window . fetch ;
37
37
38
- const ReactCurrentDispatcher =
39
- React . __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED
40
- . ReactCurrentDispatcher ;
41
-
42
38
function getResultMap ( ) : Map < string , Result > {
43
- return ReactCurrentDispatcher . current . getCacheForType ( createResultMap ) ;
39
+ return getCacheForType ( createResultMap ) ;
44
40
}
45
41
46
42
function createResultMap ( ) : Map < string , Result > {
Original file line number Diff line number Diff line change @@ -11,7 +11,7 @@ import type {Wakeable} from 'shared/ReactTypes';
11
11
12
12
import * as http from 'http' ;
13
13
import * as https from 'https' ;
14
- import * as React from 'react' ;
14
+ import { getCacheForType } from 'react' ;
15
15
16
16
type FetchResponse = { |
17
17
// Properties
@@ -74,12 +74,8 @@ type RejectedResult = {|
74
74
75
75
type Result < V > = PendingResult | ResolvedResult < V > | RejectedResult ;
76
76
77
- const ReactCurrentDispatcher =
78
- React . __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED
79
- . ReactCurrentDispatcher ;
80
-
81
77
function getResultMap ( ) : Map < string , Result < FetchResponse >> {
82
- return ReactCurrentDispatcher . current . getCacheForType ( createResultMap ) ;
78
+ return getCacheForType ( createResultMap ) ;
83
79
}
84
80
85
81
function createResultMap ( ) : Map < string , Result < FetchResponse >> {
Original file line number Diff line number Diff line change @@ -42,6 +42,8 @@ export {
42
42
__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED ,
43
43
createFactory ,
44
44
// exposeConcurrentModeAPIs
45
+ getCacheForType ,
46
+ getCacheForType as unstable_getCacheForType ,
45
47
useTransition ,
46
48
useTransition as unstable_useTransition ,
47
49
useDeferredValue ,
Original file line number Diff line number Diff line change @@ -40,6 +40,7 @@ export {
40
40
__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED ,
41
41
createFactory ,
42
42
// exposeConcurrentModeAPIs
43
+ getCacheForType as unstable_getCacheForType ,
43
44
useTransition as unstable_useTransition ,
44
45
useDeferredValue as unstable_useDeferredValue ,
45
46
startTransition as unstable_startTransition ,
Original file line number Diff line number Diff line change @@ -70,6 +70,8 @@ export {
70
70
version ,
71
71
__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED ,
72
72
createFactory ,
73
+ getCacheForType ,
74
+ getCacheForType as unstable_getCacheForType ,
73
75
useTransition ,
74
76
useTransition as unstable_useTransition ,
75
77
startTransition ,
Original file line number Diff line number Diff line change @@ -41,6 +41,8 @@ export {
41
41
version ,
42
42
__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED ,
43
43
// exposeConcurrentModeAPIs
44
+ getCacheForType ,
45
+ getCacheForType as unstable_getCacheForType ,
44
46
useTransition ,
45
47
useTransition as unstable_useTransition ,
46
48
useDeferredValue ,
Original file line number Diff line number Diff line change @@ -33,6 +33,7 @@ import {lazy} from './ReactLazy';
33
33
import { forwardRef } from './ReactForwardRef' ;
34
34
import { memo } from './ReactMemo' ;
35
35
import {
36
+ getCacheForType ,
36
37
useCallback ,
37
38
useContext ,
38
39
useEffect ,
@@ -105,6 +106,7 @@ export {
105
106
// Deprecated behind disableCreateFactory
106
107
createFactory ,
107
108
// Concurrent Mode
109
+ getCacheForType ,
108
110
useTransition ,
109
111
startTransition ,
110
112
useDeferredValue ,
Original file line number Diff line number Diff line change @@ -36,6 +36,11 @@ function resolveDispatcher() {
36
36
return dispatcher ;
37
37
}
38
38
39
+ export function getCacheForType < T > ( resourceType : ( ) = > T ) : T {
40
+ const dispatcher = resolveDispatcher ( ) ;
41
+ return dispatcher . getCacheForType ( resourceType ) ;
42
+ }
43
+
39
44
export function useContext < T > (
40
45
Context : ReactContext < T > ,
41
46
unstable_observedBits : number | boolean | void ,
You can’t perform that action at this time.
0 commit comments