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

Function requestCacheFromPool

packages/react-reconciler/src/ReactFiberTransition.js:226–252  ·  view source on GitHub ↗
(renderLanes: Lanes)

Source from the content-addressed store, hash-verified

224}
225
226export function requestCacheFromPool(renderLanes: Lanes): Cache {
227 // Similar to previous function, except if there's not already a cache in the
228 // pool, we allocate a new one.
229 const cacheFromPool = peekCacheFromPool();
230 if (cacheFromPool !== null) {
231 return cacheFromPool;
232 }
233
234 // Create a fresh cache and add it to the root cache pool. A cache can have
235 // multiple owners:
236 // - A cache pool that lives on the FiberRoot. This is where all fresh caches
237 // are originally created (TODO: except during refreshes, until we implement
238 // this correctly). The root takes ownership immediately when the cache is
239 // created. Conceptually, root.pooledCache is an Option<Arc<Cache>> (owned),
240 // and the return value of this function is a &Arc<Cache> (borrowed).
241 // - One of several fiber types: host root, cache boundary, suspense
242 // component. These retain and release in the commit phase.
243
244 const root = (getWorkInProgressRoot(): any);
245 const freshCache = createCache();
246 root.pooledCache = freshCache;
247 retainCache(freshCache);
248 if (freshCache !== null) {
249 root.pooledCacheLanes |= renderLanes;
250 }
251 return freshCache;
252}
253
254export function pushRootTransition(
255 workInProgress: Fiber,

Callers 1

updateCacheComponentFunction · 0.90

Calls 4

getWorkInProgressRootFunction · 0.90
createCacheFunction · 0.90
retainCacheFunction · 0.90
peekCacheFromPoolFunction · 0.85

Tested by

no test coverage detected