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

Typo in PropTypes.checkPropTypes section of Docs #299

Closed
marksmccann opened this issue Nov 9, 2019 · 5 comments · Fixed by #300
Closed

Typo in PropTypes.checkPropTypes section of Docs #299

marksmccann opened this issue Nov 9, 2019 · 5 comments · Fixed by #300

Comments

@marksmccann
Copy link

I believe there is a small typo in the PropTypes.checkPropTypes section of your README.md. Not a big deal, but wanted to point it out. It tripped me up for a little bit and wanted save the next person some time :).

It reads:

PropTypes.checkPropTypes(myPropTypes, props, 'age', 'MyComponent');

When I believe it should read:

PropTypes.checkPropTypes(myPropTypes, props, 'prop', 'MyComponent');
@ljharb
Copy link
Collaborator

ljharb commented Nov 9, 2019

No, “age” is correct - it matches the code above it in the same section.

@marksmccann
Copy link
Author

marksmccann commented Nov 10, 2019

Fair enough, I am sure you no better than I, but are you sure? In the source, that argument is labeled as the location, it even gives the example of "prop" in the description.

/**
 * Assert that the values match with the type specs.
 * Error messages are memorized and will only be shown once.
 *
 * @param {object} typeSpecs Map of name to a ReactPropType
 * @param {object} values Runtime values that need to be type-checked
 * @param {string} location e.g. "prop", "context", "child context"
 * @param {string} componentName Name of the component for error messages.
 * @param {?Function} getStack Returns the component stack.
 * @private
 */
function checkPropTypes(typeSpecs, values, location, componentName, getStack) {
    ...
    var err = Error((componentName || 'React class') + ': ' + location + ' type `' + typeSpecName + '` is invalid; ' ...);

I believe, if you ran your example it would produce this:

Warning: Failed age type: Invalid age `age` of type `string` supplied to

instead of this:

Warning: Failed prop type: Invalid prop `age` of type `string` supplied to

@ljharb
Copy link
Collaborator

ljharb commented Nov 10, 2019

ahh, I see what you mean :-D and also why the mistake was made in #248 - which should be reverted.

@marksmccann
Copy link
Author

I see you have a help wanted tag on the issue, if possible, I would love to make the update and create the PR for you.

@ljharb
Copy link
Collaborator

ljharb commented Nov 10, 2019

That’d be great; that’s indeed what the label means.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants