Allow callbacks to be enqueued during componentWillMount
Since I fixed the server-side rendering it is now possible to trigger these callbacks on the client alone. They will still be queued up on the server but they are never executed.
Sebastian Markbage committed
Jun 18, 2015 at 13:34 UTC
140af9b98584ecc7012eafeaf7b036cc512cd4c3
2 files changed
+5
-4
src/renderers/shared/reconciler/ReactUpdateQueue.js
+1
-2
@@ -117,8 +117,7 @@ var ReactUpdateQueue = {
117
// behavior we have in other enqueue* methods.
118
// We also need to ignore callbacks in componentWillMount. See
119
// enqueueUpdates.
120
- if (!internalInstance ||
121
- internalInstance === ReactLifeCycle.currentlyMountingInstance) {
120
+ if (!internalInstance) {
121
return null;
122
}
123
src/renderers/shared/reconciler/__tests__/ReactCompositeComponentState-test.js
+4
-2
@@ -147,7 +147,7 @@ describe('ReactCompositeComponent-state', function() {
147
148
React.unmountComponentAtNode(container);
149
150
- expect(stateListener.mock.calls).toEqual([
150
+ expect(stateListener.mock.calls.join('\n')).toEqual([
151
// there is no state when getInitialState() is called
152
['getInitialState', null],
153
['componentWillMount-start', 'red'],
@@ -173,6 +173,8 @@ describe('ReactCompositeComponent-state', function() {
173
['render', 'yellow'],
174
['componentDidUpdate-currentState', 'yellow'],
175
['componentDidUpdate-prevState', 'orange'],
176
+ ['setState-sunrise', 'yellow'],
177
+ ['setState-orange', 'yellow'],
178
['setState-yellow', 'yellow'],
179
['initial-callback', 'yellow'],
180
['componentWillReceiveProps-start', 'yellow'],
@@ -210,7 +212,7 @@ describe('ReactCompositeComponent-state', function() {
212
// unmountComponent()
213
// state is available within `componentWillUnmount()`
214
['componentWillUnmount', 'blue'],
213
- ]);
215
+ ].join('\n'));
216
});
217
218
it('should batch unmounts', function() {