diff --git a/react/src/lib/Giscus.tsx b/react/src/lib/Giscus.tsx index cc61c46a..decedc52 100644 --- a/react/src/lib/Giscus.tsx +++ b/react/src/lib/Giscus.tsx @@ -1,4 +1,4 @@ -import { useEffect } from 'react'; +import { useEffect, useState } from 'react'; import type { GiscusProps } from './types'; export default function Giscus({ @@ -16,10 +16,16 @@ export default function Giscus({ lang, loading, }: GiscusProps) { + const [mounted, setMounted] = useState(false); + useEffect(() => { + if (mounted) return; import('giscus'); + setMounted(true); }, []); + if (!mounted) return null; + return ( import('giscus')); - export let id: string = undefined; export let repo: `${string}/${string}`; export let repoId: string; @@ -24,20 +22,29 @@ export let theme: Theme = 'light'; export let lang: AvailableLanguage = 'en'; export let loading: Loading = 'eager'; + + let mounted = false; + + onMount(() => { + mounted = true; + import('giscus'); + }); - +{#if mounted} + +{/if} diff --git a/vue/src/lib/Giscus.vue b/vue/src/lib/Giscus.vue index f7c5c40b..d2f18107 100644 --- a/vue/src/lib/Giscus.vue +++ b/vue/src/lib/Giscus.vue @@ -1,5 +1,5 @@