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

Function readValue

packages/react-devtools-shared/src/__tests__/store-test.js:27–54  ·  view source on GitHub ↗
(promise)

Source from the content-addressed store, hash-verified

25 let withErrorsOrWarningsIgnored;
26
27 function readValue(promise) {
28 if (typeof React.use === 'function') {
29 return React.use(promise);
30 }
31
32 // Support for React < 19.0
33 switch (promise.status) {
34 case 'fulfilled':
35 return promise.value;
36 case 'rejected':
37 throw promise.reason;
38 case 'pending':
39 throw promise;
40 default:
41 promise.status = 'pending';
42 promise.then(
43 value => {
44 promise.status = 'fulfilled';
45 promise.value = value;
46 },
47 reason => {
48 promise.status = 'rejected';
49 promise.reason = reason;
50 },
51 );
52 throw promise;
53 }
54 }
55
56 beforeAll(() => {
57 // JSDDOM doesn'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