mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
Ensure that setState update function's context is undefined
This commit is contained in:
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;
|
||||
|
||||
Reference in New Issue
Block a user