chore: Refactor ThemePage component to fetch readme asynchronously

This commit is contained in:
Mauro Balades
2024-08-25 00:09:03 +02:00
parent c691a4e7e8
commit ba4372b912

View File

@@ -9,7 +9,6 @@ import { ChevronLeft, LoaderCircleIcon } from "lucide-react";
import { useParams } from "next/navigation"; import { useParams } from "next/navigation";
export default async function ThemePage() { export default async function ThemePage() {
const [readme, setReadme] = useState<string | null>(null);
const params = useParams<{ theme: string }>(); const params = useParams<{ theme: string }>();
const { theme: themeID } = params; const { theme: themeID } = params;
@@ -18,9 +17,7 @@ export default async function ThemePage() {
return <div>Theme not found</div>; return <div>Theme not found</div>;
} }
useEffect(() => { const readme = await getThemeMarkdown(theme);
getThemeMarkdown(theme).then(setReadme);
}, []);
return ( return (
<div className="mt-24 lg:mt-56 flex-col lg:flex-row flex mx-auto items-start relative"> <div className="mt-24 lg:mt-56 flex-col lg:flex-row flex mx-auto items-start relative">