Skip to content

Stance on React 0.14 stateless function components #612

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

Closed
jaroslawr opened this issue Dec 7, 2015 · 6 comments
Closed

Stance on React 0.14 stateless function components #612

jaroslawr opened this issue Dec 7, 2015 · 6 comments
Labels

Comments

@jaroslawr
Copy link

The React part of the coding standard, with its insistence of using classes for components, when read literally seems to be prohibiting the now officially recommended stateless function components:

var Aquarium = ({species}) => (
  <Tank>
    {getFish(species)}
  </Tank>
);

https://facebook.github.io/react/blog/2015/10/07/react-v0.14.html

I guess this was just written before React 0.14. Any chances of taking some more explicit stance on those in the coding standard?

@goatslacker
Copy link
Collaborator

We don't use React 0.14 just quite yet so we don't have a stance on it.

If you're just looking for opinions then I believe that stateless function components should make up a vast majority of your components therefore I'd use those over React.createClass and extends React.Component.

@justjake
Copy link
Collaborator

justjake commented Dec 7, 2015

I agree with @goatslacker - stateless functional components are fantastic, and once we upgrade to 0.14 we'll upgrade our styleguide to extol their virtues.

@jacobrask
Copy link

Maybe the linter could even suggest to use a stateless functional component if no lifecycle methods or component state is used?

@goatslacker
Copy link
Collaborator

Can't we close this? Is there more work that needs to be done here?

@jacobrask that seems like a feature request for eslint-react

@ljharb
Copy link
Collaborator

ljharb commented Jan 22, 2016

I think #575 clarifies our stance.

I filed jsx-eslint/eslint-plugin-react#405 for that feature request. We'll also need jsx-eslint/eslint-plugin-react#357 and jsx-eslint/eslint-plugin-react#354.

@ljharb ljharb closed this as completed Jan 22, 2016
@ljharb
Copy link
Collaborator

ljharb commented Jan 27, 2016

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

No branches or pull requests

5 participants