-
Notifications
You must be signed in to change notification settings - Fork 47.8k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Add React.startTransition #19696
Add React.startTransition #19696
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/** | ||
* Copyright (c) Facebook, Inc. and its affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
* | ||
* @flow | ||
*/ | ||
|
||
import ReactCurrentBatchConfig from './ReactCurrentBatchConfig'; | ||
|
||
// Default to an arbitrarily large timeout. Effectively, this is infinite. The | ||
// eventual goal is to never timeout when refreshing already visible content. | ||
const IndefiniteTimeoutConfig = {timeoutMs: 100000}; | ||
|
||
export function startTransition(scope: () => void) { | ||
const previousConfig = ReactCurrentBatchConfig.suspense; | ||
ReactCurrentBatchConfig.suspense = IndefiniteTimeoutConfig; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: Can we rename this to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I guess it was already like that so it's fine. We can rethink the internal data structure later. |
||
try { | ||
scope(); | ||
} finally { | ||
ReactCurrentBatchConfig.suspense = previousConfig; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this also need an unprefixed export like others?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice catch, it doesn't need it but yes it should have it.