@samitouri / QOS-React / commits / c8451bd0d8

Catch first error from setState updaters

Dan Abramov committed Nov 14, 2016 at 12:55 UTC c8451bd0d84c8f41259899ecf8ef8aab8a864c05
1 file changed +4 -4
src/renderers/shared/fiber/ReactFiberUpdateQueue.js
+4 -4
@@ -71,7 +71,7 @@ exports.addCallbackToQueue = function(queue : UpdateQueue, callback: Function) :
71
72 exports.callCallbacks = function(queue : UpdateQueue, context : any) : Error | null {
73 let node : ?UpdateQueueNode = queue;
74 - let error = null;
74 + let firstError = null;
75 while (node) {
76 const callback = node.callback;
77 if (callback && !node.callbackWasCalled) {
@@ -82,13 +82,13 @@ exports.callCallbacks = function(queue : UpdateQueue, context : any) : Error | n
82 } else {
83 callback();
84 }
85 - } catch (e) {
86 - error = e;
85 + } catch (error) {
86 + firstError = firstError || error;
87 }
88 }
89 node = node.next;
90 }
91 - return error;
91 + return firstError;
92 };
93
94 exports.mergeUpdateQueue = function(queue : UpdateQueue, instance : any, prevState : any, props : any) : any {