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

prefer-stateless-function should allow components with childContextTypes #853

Closed
lencioni opened this issue Sep 20, 2016 · 2 comments
Closed

Comments

@lencioni
Copy link
Collaborator

If you try to set childContextTypes on a stateless functional component, React will give you the following warning:

childContextTypes cannot be defined on a functional component.

https://github.com/facebook/react/blob/2058d47e7bfaccf0983aaf673d86acd89d7918ce/src/renderers/shared/stack/reconciler/ReactCompositeComponent.js#L60

The prefer-stateless-function rule should allow this.

Related #501.

@lencioni
Copy link
Collaborator Author

I wonder if we should also add a rule that warns you if you are trying to add childContextTypes on a SFC. Probably should.

@ljharb
Copy link
Member

ljharb commented Sep 20, 2016

Yes, both prefer-stateless-function should skip over comps with childContextTypes, and we should have a separate rule that prevents childContextTypes on an SFC.

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

No branches or pull requests

2 participants