[guide] [react] add a note preferring normal functions for functional stateless components.

This commit is contained in:
Jordan Harband
2016-01-26 15:03:13 -08:00
parent 94776c35eb
commit da1d031ff8

View File

@@ -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>;