mirror of
https://github.com/airbnb/javascript.git
synced 2026-01-13 19:08:03 -05:00
[guide] [react] add a note preferring normal functions for functional stateless components.
This commit is contained in:
@@ -47,7 +47,7 @@
|
||||
}
|
||||
```
|
||||
|
||||
And if you don't have state or refs, prefer functions over classes:
|
||||
And if you don't have state or refs, prefer normal functions (not arrow functions) over classes:
|
||||
|
||||
```javascript
|
||||
|
||||
@@ -58,6 +58,11 @@
|
||||
}
|
||||
}
|
||||
|
||||
// bad (since arrow functions do not have a "name" property)
|
||||
const Listing = ({ hello }) => (
|
||||
<div>{hello}</div>
|
||||
);
|
||||
|
||||
// good
|
||||
function Listing({ hello }) {
|
||||
return <div>{hello}</div>;
|
||||
|
||||
Reference in New Issue
Block a user