Skip to content

Commit da1d031

Browse files
committed
[guide] [react] add a note preferring normal functions for functional stateless components.
1 parent 94776c3 commit da1d031

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

react/README.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
}
4848
```
4949

50-
And if you don't have state or refs, prefer functions over classes:
50+
And if you don't have state or refs, prefer normal functions (not arrow functions) over classes:
5151
5252
```javascript
5353
@@ -58,6 +58,11 @@
5858
}
5959
}
6060
61+
// bad (since arrow functions do not have a "name" property)
62+
const Listing = ({ hello }) => (
63+
<div>{hello}</div>
64+
);
65+
6166
// good
6267
function Listing({ hello }) {
6368
return <div>{hello}</div>;

0 commit comments

Comments
 (0)