mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
Clone on mount
This is the first step towards descriptors. This will start cloning the component when it's mounted instead of mounting the first instance. This avoids an issue where a reference to the first instance can hang around in props. Since a mounted component gets mutated, the descriptor changes. We don't need to clone the props object itself. Mutating the shallow props object of a child that's passed into you is already flawed. Those cases need to use cloneWithProps. A props object is considered shallow frozen after it leaves the render it was created in.
This commit is contained in:
1 parent
2ca810fbf3
commit
3ea3274ca4
11 files changed
+312
-102
No files matched your search
@@ -24,7 +24,7 @@ var ReactMarkupChecksum = require('ReactMarkupChecksum');
|
||||
var ReactServerRenderingTransaction =
|
||||
require('ReactServerRenderingTransaction');
|
||||
|
||||
|
||||
var instantiateReactComponent = require('instantiateReactComponent');
|
||||
var invariant = require('invariant');
|
||||
|
||||
/**
|
||||
@@ -49,7 +49,8 @@ function renderComponentToString(component) {
|
||||
transaction = ReactServerRenderingTransaction.getPooled(false);
|
||||
|
||||
return transaction.perform(function() {
|
||||
var markup = component.mountComponent(id, transaction, 0);
|
||||
var componentInstance = instantiateReactComponent(component);
|
||||
var markup = componentInstance.mountComponent(id, transaction, 0);
|
||||
return ReactMarkupChecksum.addChecksumToMarkup(markup);
|
||||
}, null);
|
||||
} finally {
|
||||
|
||||
Reference in new issue
Block a user