@samitouri / QOS-React / commits / f7dab22ac9

Ensure that setState update function's context is undefined

Andrew Clark committed Jul 27, 2016 at 13:07 UTC f7dab22ac9a3fe6d148ea8fbd6447e7122881885
1 file changed +7 -3
src/renderers/shared/fiber/ReactFiberStateQueue.js
+7 -3
@@ -53,9 +53,13 @@ exports.mergeStateQueue = function(queue : ?StateQueue, prevState : any, props :
53 }
54 let state = Object.assign({}, prevState);
55 do {
56 - const partialState = typeof node.partialState === 'function' ?
57 - node.partialState(state, props) :
58 - node.partialState;
56 + let partialState;
57 + if (typeof node.partialState === 'function') {
58 + const updateFn = node.partialState;
59 + partialState = updateFn(state, props);
60 + } else {
61 + partialState = node.partialState;
62 + }
63 state = Object.assign(state, partialState);
64 } while (node = node.next);
65 return state;