Skip to content
This repository has been archived by the owner on Sep 1, 2024. It is now read-only.

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
Contributor

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 subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants