mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
Remove isStatic
This can be replicated with a custom component that always returns false`
from `shouldComponentUpdate`. A generic implementation might look like:
```
var StaticContainer = React.createClass({
shouldComponentUpdate: function() {
return false;
},
render: function() {
return this.transferPropsTo(this.props.children[0]);
}
});
```
And then used in JSX as
`<StaticContainer><div>Hello!</div></StaticContainer>`, resulting in
only `<div>Hello!</div>` being inserted into the DOM.
This commit is contained in:
committed by
Paul O’Shannessy
parent
e1fe13d0cb
commit
f456f8fa8d
@@ -679,9 +679,7 @@ var ReactCompositeComponentMixin = {
|
||||
var currentComponent = this._renderedComponent;
|
||||
var nextComponent = this._renderValidatedComponent();
|
||||
if (currentComponent.constructor === nextComponent.constructor) {
|
||||
if (!nextComponent.props.isStatic) {
|
||||
currentComponent.receiveProps(nextComponent.props, transaction);
|
||||
}
|
||||
currentComponent.receiveProps(nextComponent.props, transaction);
|
||||
} else {
|
||||
// These two IDs are actually the same! But nothing should rely on that.
|
||||
var thisID = this._rootNodeID;
|
||||
|
||||
@@ -167,8 +167,7 @@ var ReactMultiChildMixin = {
|
||||
this.enqueueMove(curChild._domIndex, loopDomIndex);
|
||||
}
|
||||
curChildrenDOMIndex = Math.max(curChild._domIndex, curChildrenDOMIndex);
|
||||
!nextChild.props.isStatic &&
|
||||
curChild.receiveProps(nextChild.props, transaction);
|
||||
curChild.receiveProps(nextChild.props, transaction);
|
||||
curChild._domIndex = loopDomIndex;
|
||||
} else {
|
||||
if (curChild) { // !shouldUpdate && curChild => delete
|
||||
|
||||
Reference in New Issue
Block a user