Skip to content

Commit feeb2d3

Browse files
authored
Fix tsParticles.load beeing called before mounting during navigation
1 parent d760dcd commit feeb2d3

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

components/svelte/src/lib/Particles.svelte

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
let cssClass = '';
1010
export { cssClass as class };
1111
let canStart = false;
12+
let mounted = false;
1213
1314
let style = '';
1415
export { style };
@@ -45,13 +46,14 @@
4546
});
4647
4748
onMount(() => {
49+
mounted = true;
4850
void loadParticles();
4951
});
5052
5153
async function loadParticles(): Promise<void> {
5254
destroyOldContainer();
5355
54-
if (!canStart) {
56+
if (!canStart || !mounted) {
5557
return;
5658
}
5759

0 commit comments

Comments
 (0)