react/prop-types is missing in props validation on destructured prop types
See original GitHub issueI 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:
- Created 4 years ago
- Comments:6 (3 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
prop-types
catches more cases since #2301.@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.