diff --git a/src/core/shouldUpdateReactComponent.js b/src/core/shouldUpdateReactComponent.js index 90bfd6375e..42ed113a4a 100644 --- a/src/core/shouldUpdateReactComponent.js +++ b/src/core/shouldUpdateReactComponent.js @@ -12,6 +12,8 @@ "use strict"; +var monitorCodeUse = require('monitorCodeUse'); + /** * Given a `prevElement` and `nextElement`, determines if the existing * instance should be updated as opposed to being destroyed or replaced by a new @@ -30,12 +32,41 @@ function shouldUpdateReactComponent(prevElement, nextElement) { if (prevType === 'string' || prevType === 'number') { return (nextType === 'string' || nextType === 'number'); } else { - return ( - nextType === 'object' && - prevElement.type === nextElement.type && - prevElement.key === nextElement.key && - prevElement._owner === nextElement._owner - ); + if (nextType === 'object' && + prevElement.type === nextElement.type && + prevElement.key === nextElement.key) { + var ownersMatch = prevElement._owner === nextElement._owner; + var prevName = null; + var nextName = null; + var nextDisplayName = null; + if(__DEV__) { + if (!ownersMatch) { + if (prevElement._owner != null && + prevElement._owner.getPublicInstance() != null && + prevElement._owner.getPublicInstance().constructor != null) { + prevName = prevElement._owner.getPublicInstance().constructor.displayName; + } + if (nextElement._owner != null && + nextElement._owner.getPublicInstance() != null && + nextElement._owner.getPublicInstance().constructor != null) { + nextName = nextElement._owner.getPublicInstance().constructor.displayName; + } + if(nextElement.type != null && nextElement.type.displayName != null) { + nextDisplayName = nextElement.type.displayName; + } + monitorCodeUse( + 'react_should_update_owner_is_useful', + { + key: prevElement.key, + prevOwner: prevName, + nextOwner: nextName, + nextDisplayName: nextDisplayName + } + ); + } + } + return ownersMatch; + } } } return false;