Skip to content

Commit

Permalink
Merge pull request #30 from simonyiszk/27-hydration-error-fix
Browse files Browse the repository at this point in the history
27 hydration error fix
  • Loading branch information
Tschonti authored Feb 4, 2024
2 parents 71cfd83 + ddccb9f commit fb32a9e
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 16 deletions.
4 changes: 3 additions & 1 deletion src/app/page.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import dynamic from 'next/dynamic';
import Image from 'next/image';

import { metadata } from '@/app/layout';
import { ImageCarouselSection } from '@/components/image-carousel/image-carousel-section';
import { SponsorSection } from '@/components/sponsors/sponsor-section';
import { CountdownTile } from '@/components/tiles/countdown-tile';
import { GiveawayTile } from '@/components/tiles/giveaway-tile';
import { NewsletterTile } from '@/components/tiles/newsletter-tile';
import { PromoVideoTile } from '@/components/tiles/promo-video-tile';
Expand All @@ -15,6 +15,8 @@ import konfLogo from '../../public/img/konf.svg';
import redPlanet from '../../public/img/red-planet.png';
import whitePlanet from '../../public/img/white-planet.png';

const CountdownTile = dynamic(() => import('@/components/tiles/countdown-tile/countdown-tile'), { ssr: false });

export default async function Landing() {
const data = await getIndexData();
return (
Expand Down
13 changes: 13 additions & 0 deletions src/components/tiles/countdown-tile/countdown-element.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
type CountdownElementProps = {
value: any;
label: string;
};

export function CountDownElement({ value, label }: CountdownElementProps) {
return (
<div className='flex flex-col items-center'>
<p className='text-6xl font-bold'>{value}</p>
<p className='text-xl sm:text-2xl'>{label}</p>
</div>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,19 @@
import { intervalToDuration } from 'date-fns';
import { useEffect, useState } from 'react';

import { Tile } from './tile';
import { CountDownElement } from '@/components/tiles/countdown-tile/countdown-element';

type CountdownElementProps = {
value: any;
label: string;
};
function CountDownElement({ value, label }: CountdownElementProps) {
return (
<div className='flex flex-col items-center'>
<p className='text-6xl font-bold'>{value}</p>
<p className='text-xl sm:text-2xl'>{label}</p>
</div>
);
}
import { Tile } from '../tile';

export function CountdownTile() {
export default function CountdownTile() {
const target = new Date(1710846000000); // 2024. 03. 19. 12:00
const [duration, setDuration] = useState(intervalToDuration({ start: new Date(), end: target }));
const update = () => {
if (target.getTime() > Date.now()) setDuration(intervalToDuration({ start: new Date(), end: target }));
};
useEffect(() => {
setTimeout(() => setInterval(update, 1000), 2000);
const interval = setInterval(update, 1000);
return () => clearInterval(interval);
}, []);
return (
<Tile className='sm:col-span-3'>
Expand Down

0 comments on commit fb32a9e

Please sign in to comment.