You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 4b5d55f
Browse filesBrowse the repository at this point in the historyBrowse files
Copy file name to clipboardExpand all lines: CONTRIBUTING.md
+15-16Lines changed: 15 additions & 16 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -38,37 +38,36 @@ Ignore this if you're specifically describing `createElement`.
38
38
39
39
Ignore this if you're specifically writing about ES5.
40
40
41
-
#### Don't use ES6 features when equivalent ES5 features have no downsides.
41
+
#### Prefer readable syntax.
42
42
43
-
Remember that ES6 is still new to a lot of people. While we use it in many places (`const` / `let`, classes, arrow functions), if the equivalent ES5 code is just as straightforward and readable, consider using it.
44
-
45
-
In particular, you should prefer named `function` declarations over `const myFunction = () => ...` arrows for top-level functions. However, you *should* use arrow functions where they provide a tangible improvement (such as preserving `this` context inside a component). Consider both sides of the tradeoff when deciding whether to use a new feature.
43
+
Prefer named `function` declarations for components and top-level functions. Use arrow functions for inline callbacks when they make the example easier to follow.
46
44
47
45
#### Don't use features that aren't standardized yet.
48
46
49
47
For example, **don't** write this:
50
48
51
49
```js
52
-
classMyComponentextendsReact.Component {
53
-
state = {value:''};
54
-
handleChange= (e) => {
55
-
this.setState({value:e.target.value});
50
+
functionGreeting({isLoggedIn}) {
51
+
returndo {
52
+
if (isLoggedIn) {
53
+
<h1>Welcome back!</h1>;
54
+
} else {
55
+
<h1>Please sign in.</h1>;
56
+
}
56
57
};
57
58
}
58
59
```
59
60
61
+
The [`do` expression syntax](https://github.com/tc39/proposal-do-expressions) is still experimental.
0 commit comments