survivejs / react-book

From apprentice to master (CC BY-NC-ND)
https://survivejs.com/react/introduction/
2.02k stars 366 forks source link

use ES6 static method syntax #386

Closed deepak closed 8 years ago

deepak commented 8 years ago

can use ES6 static method syntax in 4.8 Understanding React Components

  • statics - statics contains static properties and method for a component

code sample there can be changed to use ES6 static method

class Note {
  render() {
    ...
  }

  static willTransitionTo() { 
    ....
  }
}

export default Note;

also need to add a section on static methods to language_features it does have a section on class-properties-and-property-initializers

bebraw commented 8 years ago

That's a good point. I could definitely mention about it there. Thanks. 👍

There's actually a gotcha related to statics. If you wrap your classes (connect, etc.), you can get interesting behavior since they won't be visible outside anymore (hidden behind the wrapper). That would be worth documenting too.

deepak commented 8 years ago

found an issue about static methods. people are discussing some solutions there