diff --git a/pages/index.tsx b/pages/index.tsx index 1bac773..e37bdcd 100644 --- a/pages/index.tsx +++ b/pages/index.tsx @@ -1,50 +1,57 @@ import Link from 'next/link' +import { useEffect, useState } from 'react' import Navbar from '../components/Navbar' -function GetTimeString() { - const hours = new Date().getHours() +const IndexPage = () => { + const [timeString, setTimeString] = useState('Morning') - if (hours < 12) { - return 'Morning' - } else if (hours >= 12 && hours <= 17) { - return 'Afternoon' - } else if (hours >= 17 && hours <= 24) { - return 'Evening' - } + useEffect(() => { + const hours = new Date().getHours() + + console.log(new Date()) + + if (hours < 12) { + setTimeString('Morning') + } else if (hours >= 12 && hours <= 17) { + setTimeString('Afternoon') + } else if (hours >= 17 && hours <= 24) { + setTimeString('Evening') + } + }) + + return ( +