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:
committed by
Paul O’Shannessy
parent
2ca810fbf3
commit
3ea3274ca4
@@ -25,6 +25,7 @@ var ReactPerf = require('ReactPerf');
|
||||
|
||||
var containsNode = require('containsNode');
|
||||
var getReactRootElementInContainer = require('getReactRootElementInContainer');
|
||||
var instantiateReactComponent = require('instantiateReactComponent');
|
||||
var invariant = require('invariant');
|
||||
var shouldUpdateReactComponent = require('shouldUpdateReactComponent');
|
||||
|
||||
@@ -296,8 +297,13 @@ var ReactMount = {
|
||||
nextComponent,
|
||||
container,
|
||||
shouldReuseMarkup) {
|
||||
var reactRootID = ReactMount._registerComponent(nextComponent, container);
|
||||
nextComponent.mountComponentIntoNode(
|
||||
|
||||
var componentInstance = instantiateReactComponent(nextComponent);
|
||||
var reactRootID = ReactMount._registerComponent(
|
||||
componentInstance,
|
||||
container
|
||||
);
|
||||
componentInstance.mountComponentIntoNode(
|
||||
reactRootID,
|
||||
container,
|
||||
shouldReuseMarkup
|
||||
@@ -309,7 +315,7 @@ var ReactMount = {
|
||||
getReactRootElementInContainer(container);
|
||||
}
|
||||
|
||||
return nextComponent;
|
||||
return componentInstance;
|
||||
}
|
||||
),
|
||||
|
||||
|
||||
Reference in New Issue
Block a user