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

Custom component detection prop validation #307

Open
bendykstra94 opened this issue Dec 16, 2019 · 1 comment
Open

Custom component detection prop validation #307

bendykstra94 opened this issue Dec 16, 2019 · 1 comment

Comments

@bendykstra94
Copy link

Hi there!

Is there a way to add custom component detection such that subclasses of a custom component can still get their props validated?

According to https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/prop-types.md#about-component-detection only components that utilize createReactClass(), inherit from React.Component or Component, or are stateless functions can have their props validated.

My use case is that I have a custom base component that almost all of my other components inherit from and would like to have validation done on those components.

If there's a place I could be pointed to to start working on this I'd be happy to!

Thanks so much!

@ljharb
Copy link
Collaborator

ljharb commented Dec 16, 2019

React strongly discourages any subclassing of components - use composition, not inheritance.

In other words, the entire pattern of having a base component has been discouraged in React for its entire existence.

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

No branches or pull requests

2 participants