When I changed something in a Vue nested component and saved it. The Vite HMR will constantly reload the component. And then it caused a warning of vue: Maximum recursive updates exceeded...
Try online Demo on stackblitz. Change something in Child1.vue and save. You can see 101 times same info and a warning in console.
Or code blow with Vue3.x + Vite4.x/5.x:
Child1.vue
<script setup lang="ts">
const emits = defineEmits(['list-change']);
emits('list-change', ['a', 'b', 'c']);
// change something and save
console.log('Child1.vue setup');
</script>
Child2.vue
<script setup lang="ts">
const props = defineProps<{
list: string[];
}>();
</script>
App.vue
<template>
<Child1 @list-change="handleListChange"></Child1>
<Child2 :list="list"></Child2>
</template>
<script setup lang="ts">
import { ref } from 'vue';
import Child1 from './components/Child1.vue';
import Child2 from './components/Child2.vue';
const list = ref<string[]>([]);
const handleListChange = (newList: string[]) => {
list.value = newList;
};
console.log('App.vue setup');
</script>
Thanks for help.
emitin thesetupthough - if you wrap it in a setTimeout then the issue goes away