mirror of
https://github.com/BradNut/weddingsite
synced 2025-09-08 17:40:36 +00:00
24 lines
639 B
JavaScript
24 lines
639 B
JavaScript
import { useState } from 'react';
|
|
import useInterval from '../utils/useInterval';
|
|
|
|
function useWeddingStart({ update = 60000 }) {
|
|
const weddingDate = 1906736400000;
|
|
const [timeToWedding, setTime] = useState(weddingDate - Date.now());
|
|
useInterval(() => {
|
|
setTime(weddingDate - Date.now());
|
|
}, update);
|
|
return {
|
|
timeToWedding,
|
|
timeAsDays: Math.ceil(timeToWedding / 1000 / 60 / 60 / 24),
|
|
};
|
|
}
|
|
|
|
export default function WeddingStart() {
|
|
const { timeToWedding, timeAsDays } = useWeddingStart({
|
|
update: 60000,
|
|
});
|
|
|
|
return (
|
|
<span style={{ color: '#e64c44', fontSize: '3.157rem' }}>{timeAsDays}</span>
|
|
);
|
|
}
|