From 58a199f22116bb5dfc155343312d1970edc3f589 Mon Sep 17 00:00:00 2001 From: Ben Alpert Date: Wed, 8 Jan 2014 14:02:31 -0800 Subject: [PATCH] Include owner name in controlled warning --- src/browser/ui/dom/components/LinkedValueUtils.js | 14 ++++++++++++-- src/core/ReactCompositeComponent.js | 8 +++++++- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/src/browser/ui/dom/components/LinkedValueUtils.js b/src/browser/ui/dom/components/LinkedValueUtils.js index e2d1feef0f9c3..76159330718c9 100644 --- a/src/browser/ui/dom/components/LinkedValueUtils.js +++ b/src/browser/ui/dom/components/LinkedValueUtils.js @@ -94,7 +94,12 @@ var LinkedValueUtils = { 'You provided a `value` prop to a form field without an ' + '`onChange` handler. This will render a read-only field. If ' + 'the field should be mutable use `defaultValue`. Otherwise, ' + - 'set either `onChange` or `readOnly`.' + 'set either `onChange` or `readOnly`.' + ( + this._owner && this._owner.constructor.displayName ? + ' Check the render method of ' + + this._owner.constructor.displayName + '.' : + '' + ) ); }, checked: function(props, propName, componentName) { @@ -108,7 +113,12 @@ var LinkedValueUtils = { 'You provided a `checked` prop to a form field without an ' + '`onChange` handler. This will render a read-only field. If ' + 'the field should be mutable use `defaultChecked`. Otherwise, ' + - 'set either `onChange` or `readOnly`.' + 'set either `onChange` or `readOnly`.' + ( + this._owner && this._owner.constructor.displayName ? + ' Check the render method of ' + + this._owner.constructor.displayName + '.' : + '' + ) ); }, onChange: ReactPropTypes.func diff --git a/src/core/ReactCompositeComponent.js b/src/core/ReactCompositeComponent.js index 668074bdae7d6..77b7415f700b3 100644 --- a/src/core/ReactCompositeComponent.js +++ b/src/core/ReactCompositeComponent.js @@ -949,7 +949,13 @@ var ReactCompositeComponentMixin = { for (var propName in propTypes) { if (propTypes.hasOwnProperty(propName)) { var error = - propTypes[propName](props, propName, componentName, location); + propTypes[propName].call( + this, + props, + propName, + componentName, + location + ); if (error instanceof Error) { warning(false, error.message); }