Remove enqueueCallback from updater API
This isn't being used anymore. Also removes addCallback from ReactFiberUpdateQueue.
Andrew Clark committed
Dec 21, 2016 at 13:03 UTC
f4c0c9997362730c2b5182d6a7db19e5e4f9fee5
5 files changed
+29
-93
src/isomorphic/modern/class/ReactNoopUpdateQueue.js
+9
-13
@@ -44,16 +44,6 @@ var ReactNoopUpdateQueue = {
44
return false;
45
},
46
47
- /**
48
- * Enqueue a callback that will be executed after all the pending updates
49
- * have processed.
50
- *
51
- * @param {ReactClass} publicInstance The instance to use as `this` context.
52
- * @param {?function} callback Called after state is updated.
53
- * @internal
54
- */
55
- enqueueCallback: function(publicInstance, callback) { },
56
-
47
/**
48
* Forces an update. This should only be invoked when it is known with
49
* certainty that we are **not** in a DOM transaction.
@@ -65,9 +55,11 @@ var ReactNoopUpdateQueue = {
55
* `componentWillUpdate` and `componentDidUpdate`.
56
*
57
* @param {ReactClass} publicInstance The instance that should rerender.
58
+ * @param {?function} callback Called after component is updated.
59
+ * @param {?string} Name of the calling function in the public API.
60
* @internal
61
*/
70
- enqueueForceUpdate: function(publicInstance) {
62
+ enqueueForceUpdate: function(publicInstance, callback, callerName) {
63
warnNoop(publicInstance, 'forceUpdate');
64
},
65
@@ -80,9 +72,11 @@ var ReactNoopUpdateQueue = {
72
*
73
* @param {ReactClass} publicInstance The instance that should rerender.
74
* @param {object} completeState Next state.
75
+ * @param {?function} callback Called after component is updated.
76
+ * @param {?string} Name of the calling function in the public API.
77
* @internal
78
*/
85
- enqueueReplaceState: function(publicInstance, completeState) {
79
+ enqueueReplaceState: function(publicInstance, completeState, callback, callerName) {
80
warnNoop(publicInstance, 'replaceState');
81
},
82
@@ -94,9 +88,11 @@ var ReactNoopUpdateQueue = {
88
*
89
* @param {ReactClass} publicInstance The instance that should rerender.
90
* @param {object} partialState Next partial state to be merged with state.
91
+ * @param {?function} callback Called after component is updated.
92
+ * @param {?string} Name of the calling function in the public API.
93
* @internal
94
*/
99
- enqueueSetState: function(publicInstance, partialState) {
95
+ enqueueSetState: function(publicInstance, partialState, callback, callerName) {
96
warnNoop(publicInstance, 'setState');
97
},
98
};
src/renderers/dom/stack/server/ReactServerUpdateQueue.js
+20
-20
@@ -58,20 +58,6 @@ class ReactServerUpdateQueue {
58
return false;
59
}
60
61
- /**
62
- * Enqueue a callback that will be executed after all the pending updates
63
- * have processed.
64
- *
65
- * @param {ReactClass} publicInstance The instance to use as `this` context.
66
- * @param {?function} callback Called after state is updated.
67
- * @internal
68
- */
69
- enqueueCallback(publicInstance: ReactComponent<any, any, any>, callback?: Function, callerName?: string) {
70
- if (this.transaction.isInTransaction()) {
71
- ReactUpdateQueue.enqueueCallback(publicInstance, callback, callerName);
72
- }
73
- }
74
-
61
/**
62
* Forces an update. This should only be invoked when it is known with
63
* certainty that we are **not** in a DOM transaction.
@@ -83,11 +69,13 @@ class ReactServerUpdateQueue {
69
* `componentWillUpdate` and `componentDidUpdate`.
70
*
71
* @param {ReactClass} publicInstance The instance that should rerender.
72
+ * @param {?function} callback Called after component is updated.
73
+ * @param {?string} Name of the calling function in the public API.
74
* @internal
75
*/
88
- enqueueForceUpdate(publicInstance: ReactComponent<any, any, any>) {
76
+ enqueueForceUpdate(publicInstance: ReactComponent<any, any, any>, callback?: Function, callerName?: string) {
77
if (this.transaction.isInTransaction()) {
90
- ReactUpdateQueue.enqueueForceUpdate(publicInstance);
78
+ ReactUpdateQueue.enqueueForceUpdate(publicInstance, callback, callerName);
79
} else {
80
warnNoop(publicInstance, 'forceUpdate');
81
}
@@ -102,11 +90,18 @@ class ReactServerUpdateQueue {
90
*
91
* @param {ReactClass} publicInstance The instance that should rerender.
92
* @param {object|function} completeState Next state.
93
+ * @param {?function} callback Called after component is updated.
94
+ * @param {?string} Name of the calling function in the public API.
95
* @internal
96
*/
107
- enqueueReplaceState(publicInstance: ReactComponent<any, any, any>, completeState: Object|Function) {
97
+ enqueueReplaceState(
98
+ publicInstance: ReactComponent<any, any, any>,
99
+ completeState: Object|Function,
100
+ callback?: Function,
101
+ callerName?: string
102
+ ) {
103
if (this.transaction.isInTransaction()) {
109
- ReactUpdateQueue.enqueueReplaceState(publicInstance, completeState);
104
+ ReactUpdateQueue.enqueueReplaceState(publicInstance, completeState, callback, callerName);
105
} else {
106
warnNoop(publicInstance, 'replaceState');
107
}
@@ -122,9 +117,14 @@ class ReactServerUpdateQueue {
117
* @param {object|function} partialState Next partial state to be merged with state.
118
* @internal
119
*/
125
- enqueueSetState(publicInstance: ReactComponent<any, any, any>, partialState: Object|Function) {
120
+ enqueueSetState(
121
+ publicInstance: ReactComponent<any, any, any>,
122
+ partialState: Object|Function,
123
+ callback?: Function,
124
+ callerName?: string
125
+ ) {
126
if (this.transaction.isInTransaction()) {
127
- ReactUpdateQueue.enqueueSetState(publicInstance, partialState);
127
+ ReactUpdateQueue.enqueueSetState(publicInstance, partialState, callback, callerName);
128
} else {
129
warnNoop(publicInstance, 'setState');
130
}
src/renderers/shared/fiber/ReactFiberClassComponent.js
-7
@@ -22,7 +22,6 @@ var {
22
addUpdate,
23
addReplaceUpdate,
24
addForceUpdate,
25
- addCallback,
25
beginUpdateQueue,
26
} = require('ReactFiberUpdateQueue');
27
var { hasContextChanged } = require('ReactFiberContext');
@@ -60,12 +59,6 @@ module.exports = function(
59
addForceUpdate(fiber, callback || null, priorityLevel);
60
scheduleUpdate(fiber, priorityLevel);
61
},
63
- enqueueCallback(instance, callback) {
64
- const fiber = ReactInstanceMap.get(instance);
65
- const priorityLevel = getPriorityContext();
66
- addCallback(fiber, callback || null, priorityLevel);
67
- scheduleUpdate(fiber, priorityLevel);
68
- },
62
};
63
64
function checkShouldComponentUpdate(workInProgress, oldProps, newProps, newState, newContext) {
src/renderers/shared/fiber/ReactFiberUpdateQueue.js
-19
@@ -350,25 +350,6 @@ function addForceUpdate(
350
}
351
exports.addForceUpdate = addForceUpdate;
352
353
-
354
-function addCallback(
355
- fiber : Fiber,
356
- callback: Callback,
357
- priorityLevel : PriorityLevel
358
-) : void {
359
- const update : Update = {
360
- priorityLevel,
361
- partialState: null,
362
- callback,
363
- isReplace: false,
364
- isForced: false,
365
- isTopLevelUnmount: false,
366
- next: null,
367
- };
368
- insertUpdate(fiber, update);
369
-}
370
-exports.addCallback = addCallback;
371
-
353
function getPendingPriority(queue : UpdateQueue) : PriorityLevel {
354
return queue.first ? queue.first.priorityLevel : NoWork;
355
}
src/renderers/shared/stack/reconciler/ReactUpdateQueue.js
-34
@@ -112,40 +112,6 @@ var ReactUpdateQueue = {
112
}
113
},
114
115
- /**
116
- * Enqueue a callback that will be executed after all the pending updates
117
- * have processed.
118
- *
119
- * @param {ReactClass} publicInstance The instance to use as `this` context.
120
- * @param {?function} callback Called after state is updated.
121
- * @param {string} callerName Name of the calling function in the public API.
122
- * @internal
123
- */
124
- enqueueCallback: function(publicInstance, callback, callerName) {
125
- ReactUpdateQueue.validateCallback(callback, callerName);
126
- var internalInstance = getInternalInstanceReadyForUpdate(publicInstance);
127
-
128
- // Previously we would throw an error if we didn't have an internal
129
- // instance. Since we want to make it a no-op instead, we mirror the same
130
- // behavior we have in other enqueue* methods.
131
- // We also need to ignore callbacks in componentWillMount. See
132
- // enqueueUpdates.
133
- if (!internalInstance) {
134
- return null;
135
- }
136
-
137
- if (internalInstance._pendingCallbacks) {
138
- internalInstance._pendingCallbacks.push(callback);
139
- } else {
140
- internalInstance._pendingCallbacks = [callback];
141
- }
142
- // TODO: The callback here is ignored when setState is called from
143
- // componentWillMount. Either fix it or disallow doing so completely in
144
- // favor of getInitialState. Alternatively, we can disallow
145
- // componentWillMount during server-side rendering.
146
- enqueueUpdate(internalInstance);
147
- },
148
-
115
enqueueCallbackInternal: function(internalInstance, callback) {
116
if (internalInstance._pendingCallbacks) {
117
internalInstance._pendingCallbacks.push(callback);