Ensure that setState update function's context is undefined

This commit is contained in:
Andrew Clark
2016-09-13 15:26:47 -07:00
committed by Sebastian Markbage
parent 97dac74c40
commit f7dab22ac9
@@ -53,9 +53,13 @@ exports.mergeStateQueue = function(queue : ?StateQueue, prevState : any, props :
}
let state = Object.assign({}, prevState);
do {
const partialState = typeof node.partialState === 'function' ?
node.partialState(state, props) :
node.partialState;
let partialState;
if (typeof node.partialState === 'function') {
const updateFn = node.partialState;
partialState = updateFn(state, props);
} else {
partialState = node.partialState;
}
state = Object.assign(state, partialState);
} while (node = node.next);
return state;