score:5

Accepted answer

you can change your code with es2015 like this

class text extends react.component {
  constructor() {
    super();
    this.state = { currenttime: (new date()).tostring() };
  }

  componentdidmount() {
    setinterval(() => this.updatecurrenttime(), 1000);
  }

  updatecurrenttime() {
    this.setstate({
      currenttime: (new date()).tostring()
    });
  }

  render() {
    return <div>
      <span>hello my name is { this.props.name }</span>
      <span>and i was born { this.props.startdate }</span>
      <span>and i now it's { this.state.currenttime }</span>
    </div>  
  }
};

let paragraph = () => {
  return <div classname="mysupertable">
    <text name="dodo" startdate={ (new date()).tostring() } />
  </div>
};

example

react - reusable components

score:1

as you said, you wanted use es6 as much as possible. so then instead of using createclass, you can use 'react.component', you can find more info here.

and then to use, arrow mark you can use babel, preset-2015.


Related Query

More Query from same tag