Skip to content

Commit

Permalink
common: Ensure component is rendered after import is finished
Browse files Browse the repository at this point in the history
  • Loading branch information
shenlu89 authored and laymonage committed Dec 15, 2024
1 parent 1498207 commit cb13db3
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 8 deletions.
3 changes: 1 addition & 2 deletions react/src/lib/Giscus.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ export default function Giscus({

useEffect(() => {
if (mounted) return;
void import('giscus');
setMounted(true);
void import('giscus').then(() => setMounted(true));
}, []);

if (!mounted) return null;
Expand Down
3 changes: 1 addition & 2 deletions solid/src/lib/Giscus.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ export default function Giscus(props: GiscusProps) {

createEffect(() => {
if (mounted()) return;
void import('giscus');
setMounted(true);
void import('giscus').then(() => setMounted(true));
});

// Note: make sure to use kebab-case for the web component's attributes,
Expand Down
3 changes: 1 addition & 2 deletions svelte/src/lib/Giscus.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@
let mounted = false;
onMount(() => {
mounted = true;
void import('giscus');
void import('giscus').then(() => (mounted = true));
});
</script>

Expand Down
3 changes: 1 addition & 2 deletions vue/src/lib/Giscus.vue
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ defineProps<{
const mounted = ref(false);
onMounted(() => {
mounted.value = true;
import('giscus');
import('giscus').then(() => mounted.value = true);
});
</script>

Expand Down

0 comments on commit cb13db3

Please sign in to comment.