Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include owner name in controlled <input> warning #849

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions src/browser/ui/dom/components/LinkedValueUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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
Expand Down
8 changes: 7 additions & 1 deletion src/core/ReactCompositeComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This exposes internals (like _owner) to a public API. Please, no? At least expose the minimal API, e.g. by passing ownerName as an argument.
@sebmarkbage

this,
props,
propName,
componentName,
location
);
if (error instanceof Error) {
warning(false, error.message);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we just always wrap the user provide message with the owner name? Seems like this could be useful to find any component failing prop types.
@sebmarkbage

}
Expand Down