MCPcopy Index your code
hub / github.com/react/react / getCacheForType

Function getCacheForType

packages/react-reconciler/src/ReactFiberAsyncDispatcher.js:18–26  ·  view source on GitHub ↗
(resourceType: () => T)

Source from the content-addressed store, hash-verified

16import {current as currentOwner} from './ReactCurrentFiber';
17
18function getCacheForType<T>(resourceType: () => T): T {
19 const cache: Cache = readContext(CacheContext);
20 let cacheForType: T | void = (cache.data.get(resourceType): any);
21 if (cacheForType === undefined) {
22 cacheForType = resourceType();
23 cache.data.set(resourceType, cacheForType);
24 }
25 return cacheForType;
26}
27
28function cacheSignal(): null | AbortSignal {
29 const cache: Cache = readContext(CacheContext);

Callers 9

readTextFunction · 0.50
readTextFunction · 0.50
readTextFunction · 0.50
readTextFunction · 0.50
readTextFunction · 0.50
readTextFunction · 0.50
readTextFunction · 0.50
readTextFunction · 0.50
readTextFunction · 0.50

Calls 3

readContextFunction · 0.90
setMethod · 0.80
getMethod · 0.65

Tested by 9

readTextFunction · 0.40
readTextFunction · 0.40
readTextFunction · 0.40
readTextFunction · 0.40
readTextFunction · 0.40
readTextFunction · 0.40
readTextFunction · 0.40
readTextFunction · 0.40
readTextFunction · 0.40