Skip to content

Commit 60ee711

Browse files
committed
Leave syntax guidance out of contributor cleanup
1 parent f139022 commit 60ee711

1 file changed

Lines changed: 13 additions & 14 deletions

File tree

‎CONTRIBUTING.md‎

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ Ignore this if you're specifically writing about ES5.
4040

4141
#### Don't use ES6 features when equivalent ES5 features have no downsides.
4242

43-
While we use ES6 in many places (`const` / `let`, classes, arrow functions), if the equivalent ES5 code is just as straightforward and readable, consider using it.
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.
4444

4545
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.
4646

@@ -49,27 +49,26 @@ In particular, you should prefer named `function` declarations over `const myFun
4949
For example, **don't** write this:
5050

5151
```js
52-
function Greeting({isLoggedIn}) {
53-
return do {
54-
if (isLoggedIn) {
55-
<h1>Welcome back!</h1>;
56-
} else {
57-
<h1>Please sign in.</h1>;
58-
}
52+
class MyComponent extends React.Component {
53+
state = {value: ''};
54+
handleChange = (e) => {
55+
this.setState({value: e.target.value});
5956
};
6057
}
6158
```
6259

63-
The [`do` expression syntax](https://github.com/tc39/proposal-do-expressions) is still experimental.
64-
6560
Instead, **do** write this:
6661

6762
```js
68-
function Greeting({isLoggedIn}) {
69-
if (isLoggedIn) {
70-
return <h1>Welcome back!</h1>;
63+
class MyComponent extends React.Component {
64+
constructor(props) {
65+
super(props);
66+
this.handleChange = this.handleChange.bind(this);
67+
this.state = {value: ''};
68+
}
69+
handleChange(e) {
70+
this.setState({value: e.target.value});
7171
}
72-
return <h1>Please sign in.</h1>;
7372
}
7473
```
7574

0 commit comments

Comments
 (0)