Skip to content

Instantly share code, notes, and snippets.

@sakshamchhimwal
Created October 24, 2023 20:24
Show Gist options
  • Save sakshamchhimwal/4ae384d0c4239240da5bab7128b30ca0 to your computer and use it in GitHub Desktop.
Save sakshamchhimwal/4ae384d0c4239240da5bab7128b30ca0 to your computer and use it in GitHub Desktop.
Tasks Solution
// Location: app/(login)/login/page.tsx
"use client"
import { useState } from "react"
import LoginLayout from "./layout";
export default function Page() {
const [name, setName] = useState("")
const [date, setDate] = useState(Date.now().toString());
const [secs, setSecs] = useState(0);
setTimeout(() => {
const currTime = new Date(Date.now());
setSecs(currTime.getUTCSeconds());
setDate(currTime.toTimeString());
}, 1000);
return (
<>
<input type="text" onChange={(e) => { setName(e.target.value) }} />
<br />
<div>{name === "" ? "Hello" : name}</div>
<div>Seconds: {secs}</div>
<div>Date: {date}</div>
</>
)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment