PropTypes aren't removed when extending via Object.assign()
See original GitHub issueWhen a component extends from parent and the properties are extended, they are not removed.
Sample Code:
export default class ComponentB extends ComponentA {
static propTypes = Object.assign({}, {
stringKey: PropTypes.string.isRequired,
}, ComponentA.propTypes)
}
Issue Analytics
- State:
- Created 6 years ago
- Comments:9 (5 by maintainers)
Top Results From Across the Web
Invariant Violation: ViewPropTypes has been removed from ...
`ERROR Invariant Violation: ViewPropTypes has been removed from React Native. Migrate to ViewPropTypes exported from 'deprecated-react-native-prop-types'. ERROR ...
Read more >React eslint error missing in props validation - Stack Overflow
I got this error because I copied and pasted the object from a different with a slightly different name and forgot to change...
Read more >How to validate React props using PropTypes - LogRocket Blog
Learn how to validate props with React PropTypes, React's internal mechanism for adding type checking to component props.
Read more >Common code mistakes in React that you (maybe) made
Inspired by some articles, I decided to write this article and describe how to avoid common code mistakes in React app and why...
Read more >Inheritance and the prototype chain - JavaScript | MDN
We can now use the new operator to create an instance of doSomething() based on this prototype. To use the new operator, call...
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

Here is an example use case. Think of complex logic that is required for rendering common components.
I’ll submit a PR which addresses this hopefully by this weekend … should just be a quick fix in the
isReactClass()to use a while loop instead of returning false.Thanks for being open @oliviertassinari
I have tried out your example, that’s working as expected on my end. Here is the output:
Still feel free to submit a PR if you find anything not working as expected.