Nothing here yet.
Nothing here yet.
No blogs yet.
That's how I've done it during React learning from official docs. You can see it live here: https://react-play-neone.herokuapp.com/ class Clock extends React.Component { constructor(props) { super(props); this.state = {date: new Date()}; } componentDidMount() { this.timerID = setInterval(() => this.tick(), 1000); } componentWillUnmount() { clearInterval(this.timerID); } tick() { this.setState({ date: new Date() }); } render() { return ( <div> <FormattedDate date={this.state.date} /> </div> ); } } Here is more info about arrow functions introduced in es6 http://es6-features.org/#ExpressionBodies