From 33266dfad668b7bf70bbbdcc9b7b06035f582954 Mon Sep 17 00:00:00 2001 From: Sage Abdullah Date: Sat, 14 May 2022 10:33:08 +0700 Subject: [PATCH 1/4] react: Only render after component is mounted --- react/src/lib/Giscus.tsx | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) 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 ( Date: Sat, 14 May 2022 10:33:18 +0700 Subject: [PATCH 2/4] vue: Only render after component is mounted --- vue/src/lib/Giscus.vue | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) 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 @@