Jak możemy zaktualizować czas w React JS
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 (
<div className="App">
<div className="clock-container">
<h3 className="digitalClock">digital clock</h3>
<div className="time-container">{cTime}</div>
</div>
</div>
);
};
export default App;
Nasty Nightingale