Property initializers in reagent classes?

I started to see this template pop up:

class MyComponent extends React.Component {
  static propTypes = {
    // ...
  };

  //...
}

I thought that at first it was not valid until I looked and realized that it was ES7. Is this safe (i.e. future) syntax to use? I ask because I understand that not all syntaxes in ES6 and ES7 are approved, many are simply offered. I like this better than what I used:

class MyComponent extends React.Component {
  // ...
}

MyComponent.propTypes = { .. }
+4
source share
1 answer

Yes, it is safe and promising. These features are part of ES6 , not ES7, and this is an approved standard.

, .

+2

All Articles