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 9
9
10
10
import type { Wakeable } from 'shared/ReactTypes' ;
11
11
12
- import * as React from 'react' ;
12
+ import { unstable_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 unstable_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 { unstable_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 unstable_getCacheForType ( createResultMap ) ;
83
79
}
84
80
85
81
function createResultMap ( ) : Map < string , Result < FetchResponse >> {
Original file line number Diff line number Diff line change @@ -50,6 +50,7 @@ export {
50
50
startTransition as unstable_startTransition ,
51
51
SuspenseList ,
52
52
SuspenseList as unstable_SuspenseList ,
53
+ unstable_getCacheForType ,
53
54
// enableScopeAPI
54
55
unstable_Scope ,
55
56
unstable_useOpaqueIdentifier ,
Original file line number Diff line number Diff line change @@ -45,6 +45,7 @@ export {
45
45
startTransition as unstable_startTransition ,
46
46
SuspenseList as unstable_SuspenseList ,
47
47
unstable_useOpaqueIdentifier ,
48
+ unstable_getCacheForType ,
48
49
// enableDebugTracing
49
50
unstable_DebugTracingMode ,
50
51
} from './src/React' ;
Original file line number Diff line number Diff line change @@ -82,4 +82,5 @@ export {
82
82
unstable_createFundamental ,
83
83
unstable_Scope ,
84
84
unstable_useOpaqueIdentifier ,
85
+ unstable_getCacheForType ,
85
86
} from './src/React' ;
Original file line number Diff line number Diff line change @@ -49,6 +49,7 @@ export {
49
49
startTransition as unstable_startTransition ,
50
50
SuspenseList ,
51
51
SuspenseList as unstable_SuspenseList ,
52
+ unstable_getCacheForType ,
52
53
// enableScopeAPI
53
54
unstable_Scope ,
54
55
unstable_useOpaqueIdentifier ,
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 ,
@@ -110,6 +111,7 @@ export {
110
111
useDeferredValue ,
111
112
REACT_SUSPENSE_LIST_TYPE as SuspenseList ,
112
113
REACT_LEGACY_HIDDEN_TYPE as unstable_LegacyHidden ,
114
+ getCacheForType as unstable_getCacheForType ,
113
115
// enableFundamentalAPI
114
116
createFundamental as unstable_createFundamental ,
115
117
// enableScopeAPI
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