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

Function getText

packages/react-reconciler/src/__tests__/ReactAsyncActions-test.js:85–114  ·  view source on GitHub ↗
(text)

Source from the content-addressed store, hash-verified

83 }
84
85 function getText(text) {
86 const record = textCache.get(text);
87 if (record === undefined) {
88 const thenable = {
89 pings: [],
90 then(resolve) {
91 if (newRecord.status === 'pending') {
92 thenable.pings.push(resolve);
93 } else {
94 Promise.resolve().then(() => resolve(newRecord.value));
95 }
96 },
97 };
98 const newRecord = {
99 status: 'pending',
100 value: thenable,
101 };
102 textCache.set(text, newRecord);
103 return thenable;
104 } else {
105 switch (record.status) {
106 case 'pending':
107 return record.value;
108 case 'rejected':
109 return Promise.reject(record.value);
110 case 'resolved':
111 return Promise.resolve(record.value);
112 }
113 }
114 }
115
116 function Text({text}) {
117 Scheduler.log(text);

Callers 2

submitNewItemFunction · 0.70

Calls 2

setMethod · 0.80
getMethod · 0.65

Tested by

no test coverage detected