Skip to content

Commit 3048988

Browse files
committed
Mark the render as delayed if we have to retry
This allows the suspense config to kick in and we can wait for much longer before we're forced to give up on hydrating.
1 parent c0b08de commit 3048988

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

fixtures/ssr/src/components/Chrome.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,16 @@ export default class Chrome extends Component {
2626
<Theme.Provider value={this.state.theme}>
2727
{this.props.children}
2828
<div>
29-
<ThemeToggleButton onChange={theme => this.setState({theme})} />
29+
<ThemeToggleButton
30+
onChange={theme => {
31+
React.unstable_withSuspenseConfig(
32+
() => {
33+
this.setState({theme});
34+
},
35+
{timeoutMs: 6000}
36+
);
37+
}}
38+
/>
3039
</div>
3140
</Theme.Provider>
3241
<script

packages/react-reconciler/src/ReactFiberBeginWork.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,7 @@ import {
173173
requestCurrentTime,
174174
retryDehydratedSuspenseBoundary,
175175
scheduleWork,
176+
renderDidSuspendDelayIfPossible,
176177
} from './ReactFiberWorkLoop';
177178

178179
const ReactCurrentOwner = ReactSharedInternals.ReactCurrentOwner;
@@ -2060,6 +2061,8 @@ function updateDehydratedSuspenseComponent(
20602061
// since we now have higher priority work, but in case it doesn't, we need to prepare to
20612062
// render something, if we time out. Even if that requires us to delete everything and
20622063
// skip hydration.
2064+
// Delay having to do this as long as the suspense timeout allows us.
2065+
renderDidSuspendDelayIfPossible();
20632066
return retrySuspenseComponentWithoutHydrating(
20642067
current,
20652068
workInProgress,

0 commit comments

Comments
 (0)