MCPcopy
hub / github.com/facebook/react / readText

Function readText

packages/react-dom/src/__tests__/ReactDOMFizzServer-test.js:356–387  ·  view source on GitHub ↗
(text)

Source from the content-addressed store, hash-verified

354 }
355
356 function readText(text) {
357 const record = textCache.get(text);
358 if (record !== undefined) {
359 switch (record.status) {
360 case 'pending':
361 throw record.value;
362 case 'rejected':
363 throw record.value;
364 case 'resolved':
365 return record.value;
366 }
367 } else {
368 const thenable = {
369 pings: [],
370 then(resolve) {
371 if (newRecord.status === 'pending') {
372 thenable.pings.push(resolve);
373 } else {
374 Promise.resolve().then(() => resolve(newRecord.value));
375 }
376 },
377 };
378
379 const newRecord = {
380 status: 'pending',
381 value: thenable,
382 };
383 textCache.set(text, newRecord);
384
385 throw thenable;
386 }
387 }
388
389 function Text({text}) {
390 return text;

Callers 9

AsyncTextFunction · 0.70
BFunction · 0.70
ChildFunction · 0.70
BlockedFunction · 0.70
AsyncNoOutputFunction · 0.70
AsyncHeadFunction · 0.70
AsyncBodyFunction · 0.70
FormFunction · 0.70
BlockedOnFunction · 0.70

Calls 2

setMethod · 0.80
getMethod · 0.65

Tested by

no test coverage detected