@samitouri / QOS-React / commits / 26731ea967

unstable_batchedUpdates should return value of callback

Andrew Clark committed Oct 30, 2016 at 22:44 UTC 26731ea9671837899de80d7e71db0df93d5ca64f
3 files changed +8 -5
src/renderers/dom/fiber/ReactDOMFiber.js
+2 -2
@@ -165,8 +165,8 @@ var ReactDOM = {
165 return DOMRenderer.findHostInstance(component);
166 },
167
168 - unstable_batchedUpdates(fn : Function) : void {
169 - DOMRenderer.batchedUpdates(fn);
168 + unstable_batchedUpdates<A>(fn : () => A) : A {
169 + return DOMRenderer.batchedUpdates(fn);
170 },
171
172 };
src/renderers/shared/fiber/ReactFiberReconciler.js
+4 -1
@@ -68,7 +68,10 @@ export type Reconciler<C, I, TI> = {
68 updateContainer(element : ReactElement<any>, container : OpaqueNode) : void,
69 unmountContainer(container : OpaqueNode) : void,
70 performWithPriority(priorityLevel : PriorityLevel, fn : Function) : void,
71 - batchedUpdates(fn: Function) : void,
71 + /* eslint-disable no-undef */
72 + // FIXME: ESLint complains about type parameter
73 + batchedUpdates<A>(fn : () => A) : A,
74 + /* eslint-enable no-undef */
75
76 // Used to extract the return value from the initial render. Legacy API.
77 getPublicRootInstance(container : OpaqueNode) : (ReactComponent<any, any, any> | TI | I | null),
src/renderers/shared/fiber/ReactFiberScheduler.js
+2 -2
@@ -681,11 +681,11 @@ module.exports = function<T, P, I, TI, C>(config : HostConfig<T, P, I, TI, C>) {
681 }
682 }
683
684 - function batchedUpdates(fn: Function) {
684 + function batchedUpdates<A>(fn : () => A) : A {
685 const prev = shouldBatchUpdates;
686 shouldBatchUpdates = true;
687 try {
688 - fn();
688 + return fn();
689 } finally {
690 shouldBatchUpdates = prev;
691 }