Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

how can we update time in 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;

Comment

PREVIOUS NEXT
Code Example
Javascript :: react native remove text from string 
Javascript :: javascript clear all cookies 
Javascript :: javascript trim 
Javascript :: ajax post variable values 
Javascript :: readfilesync return buffer 
Javascript :: control audio javascript 
Javascript :: search text in div jquery 
Javascript :: hello world using alert 
Javascript :: javascript round down 
Javascript :: javascript parse xml 
Javascript :: how to get datetime javascript now 
Javascript :: jquery to br 
Javascript :: list all files in s3 bucket 
Javascript :: how to push at top of array 
Javascript :: angular production vs development mode 
Javascript :: javascript object to base64 
Javascript :: find duplicate values in array object javascript 
Javascript :: how to create a random number generator in javascript 
Javascript :: allow only numerics and few alphabets in input type js 
Javascript :: react to string 
Javascript :: how to change checkbox state in jquery 
Javascript :: how to get element of an array in javascript 
Javascript :: print object key value javascript 
Javascript :: jquery sort listing alphabetically 
Javascript :: array chaing in js 
Javascript :: js read from json 
Javascript :: how do you make a random array in javascript 
Javascript :: datatables add row 
Javascript :: spread operator merge objects 
Javascript :: create module in js 
ADD CONTENT
Topic
Content
Source link
Name
2+2 =