📜  我们如何在 React js 中更新时间 - Javascript 代码示例

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

代码示例1
import React, { useState, useEffect } from "react";
import "./App.css";
const App = () => {
  let time = new Date().toLocaleString();
  const [cTime, setTime] = useState(time);
  useEffect(() => {
    setInterval(() => {
      setTime(time);
    }, 1000);
  });
  return (
    

digital clock

{cTime}
); }; export default App;