Skip to content

Lexical binding in class. #2972

@hemanth

Description

@hemanth

Was trying the beta version and noticed:

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()}>
        Clicks: {this.state.count}
      </div>
    );
  }
}

Would bomb on jsx --harmony with Parse Error: Unexpected token =

AFAIK, new on a arrow function definitions will throw an error is not a constructor and it doesn't have a prototype as well, so I guess it can't be used with class...

//cc @sebmarkbage

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions