ReactDOMComponent optimization
Slight optimization to not do unneeded reconciles of DOM components
Pete Hunt committed
Mar 10, 2014 at 15:27 UTC
5ede7fb6191c7c587cf7099d044746d1607cd8d5
3 files changed
+9
src/browser/__tests__/ReactDOM-test.js
renamed
src/browser/ui/ReactDOMComponent.js
+9
@@ -206,6 +206,15 @@ ReactDOMComponent.Mixin = {
206
},
207
208
receiveComponent: function(nextComponent, transaction) {
209
+ if (nextComponent === this) {
210
+ // Since props and context are immutable after the component is
211
+ // mounted, we can do a cheap identity compare here to determine
212
+ // if this is a superfluous reconcile.
213
+
214
+ // TODO: compare the descriptor
215
+ return;
216
+ }
217
+
218
assertValidProps(nextComponent.props);
219
ReactComponent.Mixin.receiveComponent.call(
220
this,