Answers for "make a component update every second react"

0

make a component update every second react

import React, { Component } from 'react';

class TimeComponent extends Component {
  constructor(props){
    super(props);
    this.state = { time: Date.now() };
  }
  render(){
    return(
      <div> { this.state.time } </div>
    );
  }
  componentDidMount() {
    console.log("TimeComponent Mounted...")
  }
}

export default TimeComponent;
Posted by: Guest on October-18-2020

Code answers related to "make a component update every second react"

Code answers related to "Javascript"

Browse Popular Code Answers by Language