mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
UpdateQueue fixes
- Incorrect comparison when computing hasUpdate - isReplace should be a property of the node, not the queue
This commit is contained in:
@@ -87,6 +87,9 @@ src/renderers/art/__tests__/ReactART-test.js
|
||||
* resolves refs before componentDidMount
|
||||
* resolves refs before componentDidUpdate
|
||||
|
||||
src/renderers/dom/__tests__/ReactDOMProduction-test.js
|
||||
* should throw with an error code in production
|
||||
|
||||
src/renderers/dom/shared/__tests__/CSSPropertyOperations-test.js
|
||||
* should set style attribute when styles exist
|
||||
* should warn when using hyphenated style names
|
||||
|
||||
@@ -438,7 +438,6 @@ src/renderers/dom/__tests__/ReactDOMProduction-test.js
|
||||
* should use prod React
|
||||
* should handle a simple flow
|
||||
* should call lifecycle methods
|
||||
* should throw with an error code in production
|
||||
|
||||
src/renderers/dom/fiber/__tests__/ReactDOMFiber-test.js
|
||||
* should render strings as children
|
||||
|
||||
@@ -16,11 +16,11 @@ type UpdateQueueNode = {
|
||||
partialState: any,
|
||||
callback: ?Function,
|
||||
callbackWasCalled: boolean,
|
||||
isReplace: boolean,
|
||||
next: ?UpdateQueueNode,
|
||||
};
|
||||
|
||||
export type UpdateQueue = UpdateQueueNode & {
|
||||
isReplace: boolean,
|
||||
isForced: boolean,
|
||||
hasUpdate: boolean,
|
||||
hasCallback: boolean,
|
||||
@@ -32,8 +32,8 @@ exports.createUpdateQueue = function(partialState : mixed) : UpdateQueue {
|
||||
partialState,
|
||||
callback: null,
|
||||
callbackWasCalled: false,
|
||||
next: null,
|
||||
isReplace: false,
|
||||
next: null,
|
||||
isForced: false,
|
||||
hasUpdate: partialState != null,
|
||||
hasCallback: false,
|
||||
@@ -48,11 +48,12 @@ function addToQueue(queue : UpdateQueue, partialState : mixed) : UpdateQueue {
|
||||
partialState,
|
||||
callback: null,
|
||||
callbackWasCalled: false,
|
||||
isReplace: false,
|
||||
next: null,
|
||||
};
|
||||
queue.tail.next = node;
|
||||
queue.tail = node;
|
||||
queue.hasUpdate = queue.hasUpdate || (partialState == null);
|
||||
queue.hasUpdate = queue.hasUpdate || (partialState != null);
|
||||
return queue;
|
||||
}
|
||||
|
||||
@@ -86,8 +87,9 @@ exports.callCallbacks = function(queue : UpdateQueue, context : any) {
|
||||
|
||||
exports.mergeUpdateQueue = function(queue : UpdateQueue, instance : any, prevState : any, props : any) : any {
|
||||
let node : ?UpdateQueueNode = queue;
|
||||
let state = queue.isReplace ? null : Object.assign({}, prevState);
|
||||
let state = Object.assign({}, prevState);
|
||||
while (node) {
|
||||
state = node.isReplace ? null : state;
|
||||
let partialState;
|
||||
if (typeof node.partialState === 'function') {
|
||||
const updateFn = node.partialState;
|
||||
|
||||
Reference in New Issue
Block a user