From 5b673e753b1ab64b6ffe3cefc011275002085504 Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Sun, 28 Sep 2025 00:58:15 +0300 Subject: [PATCH] fix(website): hydration issues due to rendering on the server of client-side logic --- apps/website/src/components/DownloadButton.tsx | 8 +++++--- apps/website/src/download-helper.ts | 9 ++++++++- apps/website/src/hooks.tsx | 6 +++--- apps/website/src/pages/Home/index.tsx | 12 ++++++------ 4 files changed, 22 insertions(+), 13 deletions(-) diff --git a/apps/website/src/components/DownloadButton.tsx b/apps/website/src/components/DownloadButton.tsx index 7aac0c1e5..8ed8cf18a 100644 --- a/apps/website/src/components/DownloadButton.tsx +++ b/apps/website/src/components/DownloadButton.tsx @@ -1,16 +1,18 @@ -import { getRecommendedDownload } from "../download-helper.js"; +import { getRecommendedDownload, RecommendedDownload } from "../download-helper.js"; import "./DownloadButton.css"; import Button from "./Button.js"; import downloadIcon from "../assets/boxicons/bx-arrow-in-down-square-half.svg?raw"; import packageJson from "../../../../package.json" with { type: "json" }; +import { useEffect, useState } from "preact/hooks"; interface DownloadButtonProps { big?: boolean; } -const recommendedDownload = getRecommendedDownload(); - export default function DownloadButton({ big }: DownloadButtonProps) { + const [ recommendedDownload, setRecommendedDownload ] = useState(); + useEffect(() => setRecommendedDownload(getRecommendedDownload()), []); + return (recommendedDownload &&