Skip to content

Commit 47df5e0

Browse files
committed
docs(reconciler): link uncached promise dev warning to use() docs
Append https://react.dev/reference/react/use to the existing dev-only console.error so developers have a stable reference for supported Promise patterns with Suspense.
1 parent d1727fb commit 47df5e0

3 files changed

Lines changed: 41 additions & 2 deletions

File tree

packages/react-reconciler/src/ReactFiberThenable.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,11 +141,11 @@ export function trackUsedThenable<T>(
141141
// granular warnings.
142142
thenableStateDev.didWarnAboutUncachedPromise = true;
143143

144-
// TODO: This warning should link to a corresponding docs page.
145144
console.error(
146145
'A component was suspended by an uncached promise. Creating ' +
147146
'promises inside a Client Component or hook is not yet ' +
148-
'supported, except via a Suspense-compatible library or framework.',
147+
'supported, except via a Suspense-compatible library or framework.\n' +
148+
'See https://react.dev/reference/react/use',
149149
);
150150
}
151151
}

packages/react-reconciler/src/__tests__/ReactSuspenseList-test.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3574,6 +3574,7 @@ describe('ReactSuspenseList', () => {
35743574
'A component was suspended by an uncached promise. ' +
35753575
'Creating promises inside a Client Component or hook is not yet supported, ' +
35763576
'except via a Suspense-compatible library or framework.\n' +
3577+
'See https://react.dev/reference/react/use\n' +
35773578
' in Foo (at **)',
35783579
]);
35793580
});
@@ -3630,11 +3631,13 @@ describe('ReactSuspenseList', () => {
36303631
'A component was suspended by an uncached promise. ' +
36313632
'Creating promises inside a Client Component or hook is not yet supported, ' +
36323633
'except via a Suspense-compatible library or framework.\n' +
3634+
'See https://react.dev/reference/react/use\n' +
36333635
' in SuspenseList (at **)\n' +
36343636
' in Foo (at **)',
36353637
'A component was suspended by an uncached promise. ' +
36363638
'Creating promises inside a Client Component or hook is not yet supported, ' +
36373639
'except via a Suspense-compatible library or framework.\n' +
3640+
'See https://react.dev/reference/react/use\n' +
36383641
' in SuspenseList (at **)\n' +
36393642
' in Foo (at **)',
36403643
]);
@@ -3654,11 +3657,13 @@ describe('ReactSuspenseList', () => {
36543657
'A component was suspended by an uncached promise. ' +
36553658
'Creating promises inside a Client Component or hook is not yet supported, ' +
36563659
'except via a Suspense-compatible library or framework.\n' +
3660+
'See https://react.dev/reference/react/use\n' +
36573661
' in SuspenseList (at **)\n' +
36583662
' in Foo (at **)',
36593663
'A component was suspended by an uncached promise. ' +
36603664
'Creating promises inside a Client Component or hook is not yet supported, ' +
36613665
'except via a Suspense-compatible library or framework.\n' +
3666+
'See https://react.dev/reference/react/use\n' +
36623667
' in SuspenseList (at **)\n' +
36633668
' in Foo (at **)',
36643669
]);
@@ -3678,6 +3683,7 @@ describe('ReactSuspenseList', () => {
36783683
'A component was suspended by an uncached promise. ' +
36793684
'Creating promises inside a Client Component or hook is not yet supported, ' +
36803685
'except via a Suspense-compatible library or framework.\n' +
3686+
'See https://react.dev/reference/react/use\n' +
36813687
' in SuspenseList (at **)\n' +
36823688
' in Foo (at **)',
36833689
]);
@@ -3733,6 +3739,7 @@ describe('ReactSuspenseList', () => {
37333739
'A component was suspended by an uncached promise. ' +
37343740
'Creating promises inside a Client Component or hook is not yet supported, ' +
37353741
'except via a Suspense-compatible library or framework.\n' +
3742+
'See https://react.dev/reference/react/use\n' +
37363743
' in Foo (at **)',
37373744
]);
37383745
});

packages/react-reconciler/src/__tests__/ReactUse-test.js

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,7 @@ describe('ReactUse', () => {
257257
'A component was suspended by an uncached promise. Creating ' +
258258
'promises inside a Client Component or hook is not yet ' +
259259
'supported, except via a Suspense-compatible library or framework.\n' +
260+
'See https://react.dev/reference/react/use\n' +
260261
' in App (at **)',
261262
]);
262263
assertLog(['ABC']);
@@ -427,10 +428,12 @@ describe('ReactUse', () => {
427428
'A component was suspended by an uncached promise. Creating ' +
428429
'promises inside a Client Component or hook is not yet ' +
429430
'supported, except via a Suspense-compatible library or framework.\n' +
431+
'See https://react.dev/reference/react/use\n' +
430432
' in App (at **)',
431433
'A component was suspended by an uncached promise. Creating ' +
432434
'promises inside a Client Component or hook is not yet ' +
433435
'supported, except via a Suspense-compatible library or framework.\n' +
436+
'See https://react.dev/reference/react/use\n' +
434437
' in App (at **)',
435438
]);
436439
assertLog([
@@ -604,6 +607,7 @@ describe('ReactUse', () => {
604607
'A component was suspended by an uncached promise. ' +
605608
'Creating promises inside a Client Component or hook is not yet supported, ' +
606609
'except via a Suspense-compatible library or framework.\n' +
610+
'See https://react.dev/reference/react/use\n' +
607611
' in App (at **)',
608612
]);
609613
expect(root).toMatchRenderedOutput('Async');
@@ -653,6 +657,7 @@ describe('ReactUse', () => {
653657
'A component was suspended by an uncached promise. ' +
654658
'Creating promises inside a Client Component or hook is not yet supported, ' +
655659
'except via a Suspense-compatible library or framework.\n' +
660+
'See https://react.dev/reference/react/use\n' +
656661
' in App (at **)',
657662
]);
658663
expect(root).toMatchRenderedOutput('Async');
@@ -915,6 +920,7 @@ describe('ReactUse', () => {
915920
'A component was suspended by an uncached promise. ' +
916921
'Creating promises inside a Client Component or hook is not yet supported, ' +
917922
'except via a Suspense-compatible library or framework.\n' +
923+
'See https://react.dev/reference/react/use\n' +
918924
' in ExcitingText (at **)',
919925
]);
920926

@@ -959,6 +965,7 @@ describe('ReactUse', () => {
959965
'A component was suspended by an uncached promise. ' +
960966
'Creating promises inside a Client Component or hook is not yet supported, ' +
961967
'except via a Suspense-compatible library or framework.\n' +
968+
'See https://react.dev/reference/react/use\n' +
962969
' in Kitchen (at **)',
963970
]);
964971

@@ -980,6 +987,7 @@ describe('ReactUse', () => {
980987
'A component was suspended by an uncached promise. ' +
981988
'Creating promises inside a Client Component or hook is not yet supported, ' +
982989
'except via a Suspense-compatible library or framework.\n' +
990+
'See https://react.dev/reference/react/use\n' +
983991
' in Kitchen (at **)',
984992
]);
985993

@@ -1001,6 +1009,7 @@ describe('ReactUse', () => {
10011009
'A component was suspended by an uncached promise. ' +
10021010
'Creating promises inside a Client Component or hook is not yet supported, ' +
10031011
'except via a Suspense-compatible library or framework.\n' +
1012+
'See https://react.dev/reference/react/use\n' +
10041013
' in Kitchen (at **)',
10051014
]);
10061015
expect(root).toMatchRenderedOutput('banana dill');
@@ -1035,6 +1044,7 @@ describe('ReactUse', () => {
10351044
'A component was suspended by an uncached promise. ' +
10361045
'Creating promises inside a Client Component or hook is not yet supported, ' +
10371046
'except via a Suspense-compatible library or framework.\n' +
1047+
'See https://react.dev/reference/react/use\n' +
10381048
' in Lexicon (at **)',
10391049
]);
10401050
expect(root).toMatchRenderedOutput('aguacate abogado');
@@ -1055,6 +1065,7 @@ describe('ReactUse', () => {
10551065
'A component was suspended by an uncached promise. ' +
10561066
'Creating promises inside a Client Component or hook is not yet supported, ' +
10571067
'except via a Suspense-compatible library or framework.\n' +
1068+
'See https://react.dev/reference/react/use\n' +
10581069
' in Lexicon (at **)',
10591070
]);
10601071
expect(root).toMatchRenderedOutput('aguacate avocat');
@@ -1200,6 +1211,7 @@ describe('ReactUse', () => {
12001211
'A component was suspended by an uncached promise. ' +
12011212
'Creating promises inside a Client Component or hook is not yet supported, ' +
12021213
'except via a Suspense-compatible library or framework.\n' +
1214+
'See https://react.dev/reference/react/use\n' +
12031215
' in AsyncText (at **)',
12041216
]);
12051217
expect(root).toMatchRenderedOutput('A(Loading B...)');
@@ -1226,6 +1238,7 @@ describe('ReactUse', () => {
12261238
'A component was suspended by an uncached promise. ' +
12271239
'Creating promises inside a Client Component or hook is not yet supported, ' +
12281240
'except via a Suspense-compatible library or framework.\n' +
1241+
'See https://react.dev/reference/react/use\n' +
12291242
' in AsyncText (at **)',
12301243
]);
12311244
expect(root).toMatchRenderedOutput('AB(Loading C...)');
@@ -1244,6 +1257,7 @@ describe('ReactUse', () => {
12441257
'A component was suspended by an uncached promise. ' +
12451258
'Creating promises inside a Client Component or hook is not yet supported, ' +
12461259
'except via a Suspense-compatible library or framework.\n' +
1260+
'See https://react.dev/reference/react/use\n' +
12471261
' in AsyncText (at **)',
12481262
]);
12491263
expect(root).toMatchRenderedOutput('ABC');
@@ -1279,10 +1293,12 @@ describe('ReactUse', () => {
12791293
'A component was suspended by an uncached promise. ' +
12801294
'Creating promises inside a Client Component or hook is not yet supported, ' +
12811295
'except via a Suspense-compatible library or framework.\n' +
1296+
'See https://react.dev/reference/react/use\n' +
12821297
' in App (at **)',
12831298
'A component was suspended by an uncached promise. ' +
12841299
'Creating promises inside a Client Component or hook is not yet supported, ' +
12851300
'except via a Suspense-compatible library or framework.\n' +
1301+
'See https://react.dev/reference/react/use\n' +
12861302
' in App (at **)',
12871303
]);
12881304
expect(root).toMatchRenderedOutput('A1');
@@ -1332,6 +1348,7 @@ describe('ReactUse', () => {
13321348
'A component was suspended by an uncached promise. ' +
13331349
'Creating promises inside a Client Component or hook is not yet supported, ' +
13341350
'except via a Suspense-compatible library or framework.\n' +
1351+
'See https://react.dev/reference/react/use\n' +
13351352
' in App (at **)',
13361353
]);
13371354
expect(root).toMatchRenderedOutput('Hi');
@@ -1367,6 +1384,7 @@ describe('ReactUse', () => {
13671384
'A component was suspended by an uncached promise. ' +
13681385
'Creating promises inside a Client Component or hook is not yet supported, ' +
13691386
'except via a Suspense-compatible library or framework.\n' +
1387+
'See https://react.dev/reference/react/use\n' +
13701388
' in App (at **)',
13711389
]);
13721390
expect(root).toMatchRenderedOutput('Hi');
@@ -1424,6 +1442,7 @@ describe('ReactUse', () => {
14241442
'A component was suspended by an uncached promise. ' +
14251443
'Creating promises inside a Client Component or hook is not yet supported, ' +
14261444
'except via a Suspense-compatible library or framework.\n' +
1445+
'See https://react.dev/reference/react/use\n' +
14271446
' in App (at **)',
14281447
]);
14291448
expect(root).toMatchRenderedOutput('A');
@@ -1439,6 +1458,7 @@ describe('ReactUse', () => {
14391458
'A component was suspended by an uncached promise. ' +
14401459
'Creating promises inside a Client Component or hook is not yet supported, ' +
14411460
'except via a Suspense-compatible library or framework.\n' +
1461+
'See https://react.dev/reference/react/use\n' +
14421462
' in App (at **)',
14431463
]);
14441464
expect(root).toMatchRenderedOutput('B');
@@ -1657,6 +1677,7 @@ describe('ReactUse', () => {
16571677
'A component was suspended by an uncached promise. ' +
16581678
'Creating promises inside a Client Component or hook is not yet supported, ' +
16591679
'except via a Suspense-compatible library or framework.\n' +
1680+
'See https://react.dev/reference/react/use\n' +
16601681
' in App (at **)',
16611682
]);
16621683
expect(root).toMatchRenderedOutput('Async');
@@ -1691,6 +1712,7 @@ describe('ReactUse', () => {
16911712
'A component was suspended by an uncached promise. ' +
16921713
'Creating promises inside a Client Component or hook is not yet supported, ' +
16931714
'except via a Suspense-compatible library or framework.\n' +
1715+
'See https://react.dev/reference/react/use\n' +
16941716
' in App (at **)',
16951717
]);
16961718
expect(root).toMatchRenderedOutput('Async');
@@ -1716,6 +1738,7 @@ describe('ReactUse', () => {
17161738
'A component was suspended by an uncached promise. ' +
17171739
'Creating promises inside a Client Component or hook is not yet supported, ' +
17181740
'except via a Suspense-compatible library or framework.\n' +
1741+
'See https://react.dev/reference/react/use\n' +
17191742
' in App (at **)',
17201743
]);
17211744
expect(root).toMatchRenderedOutput('Async!');
@@ -1777,10 +1800,12 @@ describe('ReactUse', () => {
17771800
'A component was suspended by an uncached promise. ' +
17781801
'Creating promises inside a Client Component or hook is not yet supported, ' +
17791802
'except via a Suspense-compatible library or framework.\n' +
1803+
'See https://react.dev/reference/react/use\n' +
17801804
' in App (at **)',
17811805
'A component was suspended by an uncached promise. ' +
17821806
'Creating promises inside a Client Component or hook is not yet supported, ' +
17831807
'except via a Suspense-compatible library or framework.\n' +
1808+
'See https://react.dev/reference/react/use\n' +
17841809
' in App (at **)',
17851810
]);
17861811
expect(root).toMatchRenderedOutput(
@@ -1969,6 +1994,7 @@ describe('ReactUse', () => {
19691994
'A component was suspended by an uncached promise. ' +
19701995
'Creating promises inside a Client Component or hook is not yet supported, ' +
19711996
'except via a Suspense-compatible library or framework.\n' +
1997+
'See https://react.dev/reference/react/use\n' +
19721998
' in AsyncClientComponent (at **)',
19731999
]);
19742000
},
@@ -2002,10 +2028,12 @@ describe('ReactUse', () => {
20022028
'A component was suspended by an uncached promise. ' +
20032029
'Creating promises inside a Client Component or hook is not yet supported, ' +
20042030
'except via a Suspense-compatible library or framework.\n' +
2031+
'See https://react.dev/reference/react/use\n' +
20052032
' in AsyncClientComponent (at **)',
20062033
'A component was suspended by an uncached promise. ' +
20072034
'Creating promises inside a Client Component or hook is not yet supported, ' +
20082035
'except via a Suspense-compatible library or framework.\n' +
2036+
'See https://react.dev/reference/react/use\n' +
20092037
' in AsyncClientComponent (at **)',
20102038
]);
20112039
});
@@ -2044,6 +2072,7 @@ describe('ReactUse', () => {
20442072
'A component was suspended by an uncached promise. ' +
20452073
'Creating promises inside a Client Component or hook is not yet supported, ' +
20462074
'except via a Suspense-compatible library or framework.\n' +
2075+
'See https://react.dev/reference/react/use\n' +
20472076
' in App (at **)',
20482077
]);
20492078

@@ -2054,6 +2083,7 @@ describe('ReactUse', () => {
20542083
'A component was suspended by an uncached promise. ' +
20552084
'Creating promises inside a Client Component or hook is not yet supported, ' +
20562085
'except via a Suspense-compatible library or framework.\n' +
2086+
'See https://react.dev/reference/react/use\n' +
20572087
' in App (at **)',
20582088
]);
20592089

@@ -2095,6 +2125,7 @@ describe('ReactUse', () => {
20952125
'A component was suspended by an uncached promise. ' +
20962126
'Creating promises inside a Client Component or hook is not yet supported, ' +
20972127
'except via a Suspense-compatible library or framework.\n' +
2128+
'See https://react.dev/reference/react/use\n' +
20982129
' in div (at **)\n' +
20992130
' in App (at **)',
21002131
]);
@@ -2106,6 +2137,7 @@ describe('ReactUse', () => {
21062137
'A component was suspended by an uncached promise. ' +
21072138
'Creating promises inside a Client Component or hook is not yet supported, ' +
21082139
'except via a Suspense-compatible library or framework.\n' +
2140+
'See https://react.dev/reference/react/use\n' +
21092141
' in div (at **)\n' +
21102142
' in App (at **)',
21112143
]);

0 commit comments

Comments
 (0)