Inject the previous batching strategy when rendering to string (#7930)
Before this change calling renderToStringImpl would inject ReactDefaultBatchingStrategy after completion, even if a custom batching strategy was injected before. This makes renderToStringImpl keep a reference to the batching strategy before it runs and reinject it afterwards.
Islam Sharabash committed
Oct 11, 2016 at 10:57 UTC
b77a96e49645cb14254da47065f89e934274df16
2 files changed
+7
-2
src/renderers/dom/server/ReactServerRendering.js
+3
-2
@@ -12,7 +12,6 @@
12
13
var React = require('React');
14
var ReactDOMContainerInfo = require('ReactDOMContainerInfo');
15
-var ReactDefaultBatchingStrategy = require('ReactDefaultBatchingStrategy');
15
var ReactInstrumentation = require('ReactInstrumentation');
16
var ReactMarkupChecksum = require('ReactMarkupChecksum');
17
var ReactReconciler = require('ReactReconciler');
@@ -33,7 +32,9 @@ var pendingTransactions = 0;
32
*/
33
function renderToStringImpl(element, makeStaticMarkup) {
34
var transaction;
35
+ var previousBatchingStrategy;
36
try {
37
+ previousBatchingStrategy = ReactUpdates.injection.getBatchingStrategy();
38
ReactUpdates.injection.injectBatchingStrategy(ReactServerBatchingStrategy);
39
40
transaction = ReactServerRenderingTransaction.getPooled(makeStaticMarkup);
@@ -67,7 +68,7 @@ function renderToStringImpl(element, makeStaticMarkup) {
68
// currently share these stateful modules.
69
if (!pendingTransactions) {
70
ReactUpdates.injection.injectBatchingStrategy(
70
- ReactDefaultBatchingStrategy
71
+ previousBatchingStrategy
72
);
73
}
74
}
src/renderers/shared/stack/reconciler/ReactUpdates.js
+4
@@ -272,6 +272,10 @@ var ReactUpdatesInjection = {
272
);
273
batchingStrategy = _batchingStrategy;
274
},
275
+
276
+ getBatchingStrategy: function() {
277
+ return batchingStrategy;
278
+ },
279
};
280
281
var ReactUpdates = {