`react/function-component-definition` configuration violates style guide
See original GitHub issueIn eslint-config-airbnb@19.0.0
(specifically https://github.com/airbnb/javascript/commit/1bc8cabd447ef9ce69d27ae70e67eb47daeffc21), react/function-component-definition
was configured to allow only function expressions for named components:
This has the effect of disallowing function declarations:
function Foo() {
return <div />
}
While allowing only this style:
const Foo = function () {
return <div />
}
This seems like a configuration mistake, as the React style guide consistently uses function declarations for components (as does the ecosystem as a whole) and specifically points out that “relying on function name inference is discouraged”. Let me know if you agree and I’ll PR a fix.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:36
- Comments:29 (1 by maintainers)
Top Results From Across the Web
Struggling with TypeScript, React, Eslint and simple Arrow ...
With this, eslint will ONLY accept arrow functions for Components, ... this means your project won't be using the latest airbnb styleguide, ...
Read more >airbnb react/function-component-definition - You.com | The AI ...
This seems like a configuration mistake, as the React style guide consistently uses function declarations for components (as does the ecosystem as a...
Read more >Design Principles - React
Components are often described as “just functions” but in our view they need to be more than that to be useful. In React,...
Read more >Redux Style Guide
It should be passed to a React component tree via <Provider> , or referenced indirectly via middleware such as thunks. In rare cases,...
Read more >The last guide to the useEffect Hook you'll ever need
This also means that if there is no second execution of an effect scheduled, the cleanup function is invoked before the React component...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
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
@slifty yes, it will be corrected soon. btw that seems like a lot of people going to the wrong place; stack overflow isn’t the place to report problems with any software. As far as this issue can tell, there’s only 12 people, not thousands.
re the changelog, I’ll try to do a better job highlighting breaking changes in future releases.
Why? For a number of reasons:
export const Foo = (props) => {};
and then refactor that to beexport const Foo = React.memo((props) => {})
- your “Foo” name suddenly vanishes, because you were relying on inference, probably without realizing it.See also: