fix: Modify onMounted to use nextTick for DOM updates

Updated onMounted lifecycle hook to wait for DOM updates before initializing particles.
This commit is contained in:
Tomás Santos
2026-04-04 19:19:23 +01:00
committed by GitHub
parent 18b2debeab
commit 35d50b69e8
@@ -3,7 +3,7 @@
</template>
<script setup lang="ts">
import { ref, onMounted, onUnmounted, watch, useTemplateRef } from 'vue';
import { ref, onMounted, onUnmounted, watch, useTemplateRef, nextTick } from 'vue';
import { Renderer, Camera, Geometry, Program, Mesh } from 'ogl';
interface ParticlesProps {
@@ -296,8 +296,10 @@ const cleanup = () => {
program = null;
};
onMounted(() => {
initParticles();
// CHANGED onMounted
onMounted(async () => {
await nextTick(); // wait for Vue to flush its DOM updates first
initParticles();
});
onUnmounted(() => {