Browse Source

Add guidance about using new ES6 features in docs

main
Dan Abramov 7 years ago
committed by GitHub
parent
commit
b879ea4c76
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      CONTRIBUTING.md

6
CONTRIBUTING.md

@ -42,6 +42,12 @@ Ignore this if you're specifically describing `createElement`.
Ignore this if you're specifically writing about ES5.
**Don't use ES6 features when equivalent ES5 features have no downsides.**
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.
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.
**Don't use features that aren't standardized yet.**
For example, **don't** write this:

Loading…
Cancel
Save