mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
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.
This commit is contained in:
committed by
Brandon Dail
parent
7aa621daee
commit
b77a96e496
@@ -12,7 +12,6 @@
|
||||
|
||||
var React = require('React');
|
||||
var ReactDOMContainerInfo = require('ReactDOMContainerInfo');
|
||||
var ReactDefaultBatchingStrategy = require('ReactDefaultBatchingStrategy');
|
||||
var ReactInstrumentation = require('ReactInstrumentation');
|
||||
var ReactMarkupChecksum = require('ReactMarkupChecksum');
|
||||
var ReactReconciler = require('ReactReconciler');
|
||||
@@ -33,7 +32,9 @@ var pendingTransactions = 0;
|
||||
*/
|
||||
function renderToStringImpl(element, makeStaticMarkup) {
|
||||
var transaction;
|
||||
var previousBatchingStrategy;
|
||||
try {
|
||||
previousBatchingStrategy = ReactUpdates.injection.getBatchingStrategy();
|
||||
ReactUpdates.injection.injectBatchingStrategy(ReactServerBatchingStrategy);
|
||||
|
||||
transaction = ReactServerRenderingTransaction.getPooled(makeStaticMarkup);
|
||||
@@ -67,7 +68,7 @@ function renderToStringImpl(element, makeStaticMarkup) {
|
||||
// currently share these stateful modules.
|
||||
if (!pendingTransactions) {
|
||||
ReactUpdates.injection.injectBatchingStrategy(
|
||||
ReactDefaultBatchingStrategy
|
||||
previousBatchingStrategy
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -272,6 +272,10 @@ var ReactUpdatesInjection = {
|
||||
);
|
||||
batchingStrategy = _batchingStrategy;
|
||||
},
|
||||
|
||||
getBatchingStrategy: function() {
|
||||
return batchingStrategy;
|
||||
},
|
||||
};
|
||||
|
||||
var ReactUpdates = {
|
||||
|
||||
Reference in New Issue
Block a user