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

Better debugging of Expected props argument to be a plain object #7332

Closed
wants to merge 1 commit into from
Closed

Better debugging of Expected props argument to be a plain object #7332

wants to merge 1 commit into from

Conversation

catamphetamine
Copy link
Contributor

@catamphetamine catamphetamine commented Jul 22, 2016

Because no one's gonna have an idea where this warning is coming from

@ghost
Copy link

ghost commented Jul 22, 2016

Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. In order for us to review and merge your code, please sign up at https://code.facebook.com/cla - and if you have received this in error or have any questions, please drop us a line at cla@fb.com. Thanks!

@ghost ghost added the CLA Signed label Jul 22, 2016
@ghost
Copy link

ghost commented Jul 22, 2016

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks!

@@ -163,12 +163,17 @@ ReactElement.createElement = function(type, config, children) {

if (config != null) {
if (__DEV__) {
var displayName = typeof type === 'function' ?
(type.displayName || type.name || 'Unknown') :
Copy link
Contributor

Choose a reason for hiding this comment

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

'Unkown' is a weird default, imagine getting an error message like:

React.createElement(...): Expected props argument to be a plain object. Properties defined in its prototype chain will be ignored. Unknown.

Why not make it an empty string and leave as-is by default?

I'd also change the error message instead of appending the name, what about something like this:

'React.createElement(...): Expected props argument of ' + displayName +
' to be a plain object. Properties defined in its prototype chain will be ignored.'

@ghost ghost added the CLA Signed label Jul 22, 2016
@catamphetamine
Copy link
Contributor Author

@mxstbr I've added your proposed changes to the commit.
Still it says The second argument to warning must be a string literal. I don't know what is it, because it is a string as far as I can tell.

/home/travis/build/facebook/react/src/isomorphic/classic/element/ReactElement.js
  166:7
error  The second argument to warning must be a string literal  react-internal/warning-and-invariant-args

line 166:

      warning(
        /* eslint-disable no-proto */
        config.__proto__ == null || config.__proto__ === Object.prototype,
        /* eslint-enable no-proto */
        'React.createElement(...): Expected props argument of ' + displayName(type) +
        ' to be a plain object. Properties defined in its prototype chain will be ignored.'
      );

@ghost ghost added the CLA Signed label Jul 22, 2016
@ghost ghost added the CLA Signed label Jul 22, 2016
@@ -167,8 +167,8 @@ ReactElement.createElement = function(type, config, children) {
/* eslint-disable no-proto */
config.__proto__ == null || config.__proto__ === Object.prototype,
/* eslint-enable no-proto */
'React.createElement(...): Expected props argument to be a plain object. ' +
'Properties defined in its prototype chain will be ignored.'
'React.createElement(...): Expected props argument of ' + displayName(type) +
Copy link
Contributor

Choose a reason for hiding this comment

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

Better to say 'argument of type X' as it's more in line with the language I've seen in other places

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@alexzherdev Wouldn't it confuse people? "Expected props argument of type div", as if "@param {div} props".

@ghost ghost added the CLA Signed label Jul 23, 2016
@aweary
Copy link
Contributor

aweary commented Jan 26, 2017

Thanks for the PR @halt-hammerzeit! We actually removed this warning all together in #7724 so this change is no longer needed.

@aweary aweary closed this Jan 26, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants