make a component update every second react

Solutions on MaxInterview for make a component update every second react by the best coders in the world

showing results for - "make a component update every second react"
Mattia
07 Feb 2020
1import React, { Component } from 'react';
2
3class TimeComponent extends Component {
4  constructor(props){
5    super(props);
6    this.state = { time: Date.now() };
7  }
8  render(){
9    return(
10      <div> { this.state.time } </div>
11    );
12  }
13  componentDidMount() {
14    console.log("TimeComponent Mounted...")
15  }
16}
17
18export default TimeComponent;
19