React constructor ES6 vs ES7

ES7 is better because it enables the following scenarios:

  • Where declarative interpretation of expectations are useful. Some examples include editors so that they can make use of this info for typeaheads/inference, TypeScript/Flow can make use of this to allow their users to express intentions about the shapes of their classes
  • Allowing general users to use this for just human-readable documentation about properties separate from potentially complex initialization logic
  • Possibly allow VMs to pre-emptively optimize objects created from a class with some of these hints on them.

Note: When you define your state by using ES7, you are using Property initializers feature

References: Class field declarations for JavaScript

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)