mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
unstable_batchedUpdates should return value of callback
This commit is contained in:
@@ -165,8 +165,8 @@ var ReactDOM = {
|
||||
return DOMRenderer.findHostInstance(component);
|
||||
},
|
||||
|
||||
unstable_batchedUpdates(fn : Function) : void {
|
||||
DOMRenderer.batchedUpdates(fn);
|
||||
unstable_batchedUpdates<A>(fn : () => A) : A {
|
||||
return DOMRenderer.batchedUpdates(fn);
|
||||
},
|
||||
|
||||
};
|
||||
|
||||
@@ -68,7 +68,10 @@ export type Reconciler<C, I, TI> = {
|
||||
updateContainer(element : ReactElement<any>, container : OpaqueNode) : void,
|
||||
unmountContainer(container : OpaqueNode) : void,
|
||||
performWithPriority(priorityLevel : PriorityLevel, fn : Function) : void,
|
||||
batchedUpdates(fn: Function) : void,
|
||||
/* eslint-disable no-undef */
|
||||
// FIXME: ESLint complains about type parameter
|
||||
batchedUpdates<A>(fn : () => A) : A,
|
||||
/* eslint-enable no-undef */
|
||||
|
||||
// Used to extract the return value from the initial render. Legacy API.
|
||||
getPublicRootInstance(container : OpaqueNode) : (ReactComponent<any, any, any> | TI | I | null),
|
||||
|
||||
@@ -681,11 +681,11 @@ module.exports = function<T, P, I, TI, C>(config : HostConfig<T, P, I, TI, C>) {
|
||||
}
|
||||
}
|
||||
|
||||
function batchedUpdates(fn: Function) {
|
||||
function batchedUpdates<A>(fn : () => A) : A {
|
||||
const prev = shouldBatchUpdates;
|
||||
shouldBatchUpdates = true;
|
||||
try {
|
||||
fn();
|
||||
return fn();
|
||||
} finally {
|
||||
shouldBatchUpdates = prev;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user