question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

react/prop-types is missing in props validation on destructured prop types

See original GitHub issue

I just recently upgraded to the latest version and started to see this. My component has proptypes that include

/** A notification to queue up for display. */
 notification: PropTypes.shape({...NotificationPropTypes}),

NotificationPropTypes are:

import PropTypes from 'prop-types';

export default {
    /** Additional class(es) to add to the component. */
    className: PropTypes.string,
    /** A unique ID to identify the notification with. The suggested way to create this is to use <a href="https://www.npmjs.com/package/uuid#quickstart---commonjs-recommended" target="_blank">uuid</a>. */
    id: PropTypes.string.isRequired,
    /** The message body of the notification. */
    message: PropTypes.node.isRequired,
    /** Determines the characteristics of the notification. */
    type: PropTypes.oneOf(['info', 'success', 'error', 'warning']),
    /** Whether to display the close button. */
    showClose: PropTypes.bool,
    /** The time (in milliseconds) that the notification stays open for. */
    duration: PropTypes.number,
    /** Whether the notification should close itself without having to click the close button after the specified duration. */
    autoClose: PropTypes.bool,
    /** A function to execute after the notification has been hidden. Will receive the notification's props. */
    onHidden: PropTypes.func
};

Offending code:

} else if (notification && !find(this._notificationQueue, {id: notification.id})) {

Its the notification.id part that its complaining about (id). Any reason why this would start to error now?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
golopotcommented, Jul 6, 2019

I am still curious though why this didn’t error in prior versions?

prop-types catches more cases since #2301.

1reaction
reintroducingcommented, Jul 6, 2019

@ljharb that’s fair, and thanks for the explanation. I’m going to close this as a non-issue then. I am still curious though why this didn’t error in prior versions? The code has been unchanged since we were probably on ESLint 2.x way back when. Were there updates made to this plugin to change that or do you think its an internal ESLint change that got smarter and started to cause this then? Appreciate the discussion as well.

Read more comments on GitHub >

github_iconTop Results From Across the Web

False Positive: "react/prop-types [PROP_NAME] is missing ...
False Positive : "react/prop-types [PROP_NAME] is missing in props validation" when using stateless components + destructured param + Flow #498.
Read more >
missing in props validation react/prop-types
props is collecting all attributes which you pass to ChildComponent. Your data should be like this function ChildComponent(props) { const ...
Read more >
prop is missing in props validation
You need to set the static property 'propTypes' on the component to satisfy this lint error. Here is some info about React's PropTypes:...
Read more >
HTML : is missing in props validation react/prop-types - YouTube
HTML : is missing in props validation react/prop-types [ Beautify Your Computer : https://www.hows.tech/p/recommended.html ] HTML : is ...
Read more >
How to validate React props using PropTypes
Learn how to validate props with React PropTypes, React's internal mechanism for adding type checking to component props.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found