Looking at the syntax from here:
http://facebook.github.io/react/blog/2015/01/27/react-v0.13.0-beta-1.html#es7-property-initializers
ES7+ Property Initializers
Wait, assigning to properties seems like a very imperative way of defining
classes! You're right, however, we designed it this way because it's
idiomatic. We fully expect a more declarative syntax for property
initialization to arrive in future version of JavaScript. It might look
something like this:
// Future Version export class Counter extends React.Component { static
propTypes = { initialCount: React.PropTypes.number }; static defaultProps =
{ initialCount: 0 }; state = { count: this.props.initialCount }; tick() {
this.setState({ count: this.state.count + 1 }); } render() { return ( <div
onClick={this.tick.bind(this)}> Clicks: {this.state.count} </div> ); } }
Also discussed here:
https://github.com/6to5/6to5/issues/619
Are there any plans to specify this? Are there any proposals being worked
on to specify syntax similar to this or alternative syntax addressing this?
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss