Skip to content

Commit 9e4c304

Browse files
committed
Update subscription-in-startTransition warning
The message now explicitly mentions the useSyncExternalStore API.
1 parent 97673a6 commit 9e4c304

File tree

4 files changed

+25
-15
lines changed

4 files changed

+25
-15
lines changed

packages/react-reconciler/src/ReactFiberHooks.new.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1995,9 +1995,11 @@ function startTransition(setPending, callback) {
19951995
const updatedFibersCount = currentTransition._updatedFibers.size;
19961996
if (updatedFibersCount > 10) {
19971997
console.warn(
1998-
'Detected a large number of updates inside startTransition. ' +
1999-
'If this is due to a subscription please re-write it to use React provided hooks. ' +
2000-
'Otherwise concurrent mode guarantees are off the table.',
1998+
'Detected a large number of updates within a startTransition ' +
1999+
'scope. This likely means you have subscribed to an external ' +
2000+
'store. To ensure compatibility with concurrent features ' +
2001+
'like startTransition, subscriptions should be managed by the ' +
2002+
'useSyncExternalStore API.',
20012003
);
20022004
}
20032005
currentTransition._updatedFibers.clear();

packages/react-reconciler/src/ReactFiberHooks.old.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1995,9 +1995,11 @@ function startTransition(setPending, callback) {
19951995
const updatedFibersCount = currentTransition._updatedFibers.size;
19961996
if (updatedFibersCount > 10) {
19971997
console.warn(
1998-
'Detected a large number of updates inside startTransition. ' +
1999-
'If this is due to a subscription please re-write it to use React provided hooks. ' +
2000-
'Otherwise concurrent mode guarantees are off the table.',
1998+
'Detected a large number of updates within a startTransition ' +
1999+
'scope. This likely means you have subscribed to an external ' +
2000+
'store. To ensure compatibility with concurrent features ' +
2001+
'like startTransition, subscriptions should be managed by the ' +
2002+
'useSyncExternalStore API.',
20012003
);
20022004
}
20032005
currentTransition._updatedFibers.clear();

packages/react/src/ReactStartTransition.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,11 @@ export function startTransition(scope: () => void) {
2727
const updatedFibersCount = currentTransition._updatedFibers.size;
2828
if (updatedFibersCount > 10) {
2929
console.warn(
30-
'Detected a large number of updates inside startTransition. ' +
31-
'If this is due to a subscription please re-write it to use React provided hooks. ' +
32-
'Otherwise concurrent mode guarantees are off the table.',
30+
'Detected a large number of updates within a startTransition ' +
31+
'scope. This likely means you have subscribed to an external ' +
32+
'store. To ensure compatibility with concurrent features ' +
33+
'like startTransition, subscriptions should be managed by the ' +
34+
'useSyncExternalStore API.',
3335
);
3436
}
3537
currentTransition._updatedFibers.clear();

packages/react/src/__tests__/ReactStartTransition-test.js

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,11 @@ describe('ReactStartTransition', () => {
6363
});
6464
}).toWarnDev(
6565
[
66-
'Detected a large number of updates inside startTransition. ' +
67-
'If this is due to a subscription please re-write it to use React provided hooks. ' +
68-
'Otherwise concurrent mode guarantees are off the table.',
66+
'Detected a large number of updates within a startTransition ' +
67+
'scope. This likely means you have subscribed to an external ' +
68+
'store. To ensure compatibility with concurrent features ' +
69+
'like startTransition, subscriptions should be managed by the ' +
70+
'useSyncExternalStore API.',
6971
],
7072
{withoutStack: true},
7173
);
@@ -80,9 +82,11 @@ describe('ReactStartTransition', () => {
8082
});
8183
}).toWarnDev(
8284
[
83-
'Detected a large number of updates inside startTransition. ' +
84-
'If this is due to a subscription please re-write it to use React provided hooks. ' +
85-
'Otherwise concurrent mode guarantees are off the table.',
85+
'Detected a large number of updates within a startTransition ' +
86+
'scope. This likely means you have subscribed to an external ' +
87+
'store. To ensure compatibility with concurrent features ' +
88+
'like startTransition, subscriptions should be managed by the ' +
89+
'useSyncExternalStore API.',
8690
],
8791
{withoutStack: true},
8892
);

0 commit comments

Comments
 (0)