📜  让组件每秒更新一次反应 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:02:12.086000             🧑  作者: Mango

代码示例1
import React, { Component } from 'react';

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