Skip to content

Commit 06a9bf1

Browse files
shenlu89laymonage
authored andcommitted
common: Ensure component is rendered after import is finished
1 parent 1498207 commit 06a9bf1

4 files changed

Lines changed: 4 additions & 8 deletions

File tree

react/src/lib/Giscus.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@ export default function Giscus({
2222

2323
useEffect(() => {
2424
if (mounted) return;
25-
void import('giscus');
26-
setMounted(true);
25+
void import('giscus').then(() => setMounted(true));
2726
}, []);
2827

2928
if (!mounted) return null;

solid/src/lib/Giscus.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@ export default function Giscus(props: GiscusProps) {
66

77
createEffect(() => {
88
if (mounted()) return;
9-
void import('giscus');
10-
setMounted(true);
9+
void import('giscus').then(() => setMounted(true));
1110
});
1211

1312
// Note: make sure to use kebab-case for the web component's attributes,

svelte/src/lib/Giscus.svelte

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,7 @@
2828
let mounted = false;
2929
3030
onMount(() => {
31-
mounted = true;
32-
void import('giscus');
31+
void import('giscus').then(() => (mounted = true));
3332
});
3433
</script>
3534

vue/src/lib/Giscus.vue

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,7 @@ defineProps<{
3131
const mounted = ref(false);
3232
3333
onMounted(() => {
34-
mounted.value = true;
35-
import('giscus');
34+
import('giscus').then(() => (mounted.value = true));
3635
});
3736
</script>
3837

0 commit comments

Comments
 (0)