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

Function readValue

packages/react-devtools-shared/src/__tests__/store-test.js:27–54  ·  packages/react-devtools-shared/src/__tests__/store-test.js::readValue
(promise)

Source from the content-addressed store, hash-verified

25 let withErrorsOrWarningsIgnored;
26
27 function readValue(promise) {
28 if (typeof React.use === class="st">'function') {
29 return React.use(promise);
30 }
31
32 class="cm">// Support for React < 19.0
33 switch (promise.status) {
34 case class="st">'fulfilled':
35 return promise.value;
36 case class="st">'rejected':
37 throw promise.reason;
38 case class="st">'pending':
39 throw promise;
40 default:
41 promise.status = class="st">'pending';
42 promise.then(
43 value => {
44 promise.status = class="st">'fulfilled';
45 promise.value = value;
46 },
47 reason => {
48 promise.status = class="st">'rejected';
49 promise.reason = reason;
50 },
51 );
52 throw promise;
53 }
54 }
55
56 beforeAll(() => {
57 class="cm">// JSDDOM doesnclass="st">'t implement getClientRects so we're just faking one for testing purposes

Callers 4

OwnerFunction · 0.70
SuspendingComponentFunction · 0.70
NeverFunction · 0.70
ComponentFunction · 0.70

Calls 1

thenMethod · 0.65

Tested by

no test coverage detected