在使用watchEffect赋值的过程中出现 无法理解的错误 #8864
Replies: 2 comments
-
如果改成watchPostEffect 也不会出现无限循环的错误 但我想知道这是为什么 |
Beta Was this translation helpful? Give feedback.
-
Reason此时热更新会将子组件 则会一直认为 可以在项目中 function queueJob(job) {
debugger
if (!queue.length || !queue.includes(
job,
isFlushing && job.allowRecurse ? flushIndex + 1 : flushIndex
)) {
if (job.id == null) {
queue.push(job);
} else {
queue.splice(findInsertionIndex(job.id), 0, job);
}
queueFlush();
}
}
function queueFlush() {
debugger
if (!isFlushing && !isFlushPending) {
isFlushPending = true;
currentFlushPromise = resolvedPromise.then(flushJobs);
}
} 而使用 这个异常的重点是,热更新会将需要更新的组件放到 Docshttps://cn.vuejs.org/guide/essentials/watchers.html#callback-flush-timing Code检查是否超出 function checkRecursiveUpdates(seen, fn) {
if (!seen.has(fn)) {
seen.set(fn, 1);
} else {
const count = seen.get(fn);
if (count > RECURSION_LIMIT) {
const instance = fn.ownerInstance;
const componentName = instance && getComponentName(instance.type);
warn(
`Maximum recursive updates exceeded${componentName ? ` in component <${componentName}>` : ``}. This means you have a reactive effect that is mutating its own dependencies and thus recursively triggering itself. Possible sources include component template, render function, updated hook or watcher source function.`
);
return true;
} else {
seen.set(fn, count + 1);
}
}
} |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Vue version
3.3.4
Link to minimal reproduction
https://play.vuejs.org/#eNqVVctu00AU/ZXBGzvImjTqLk0ioKoESEBVKljUWRh7nLi1Z6yZsRsUecOGb0J8D+I3uPPyIwmVuojluffOuY9zrrP3XlcVbmrizb2FSHheSSSIrKtVRPOyYlyiPeIkQy3KOCuRD6F+55JESGvHU3WYKSj/IqIJo+AqxQYt1fXAf0uKgqGvjBfpC38S0YgupiYfZIKDJGVVxJLACaFFmjf6BV51jrl6fomLZeTdzdaRt1rodCZ4aqKVyWJ4oScFlJDlG3wvGIXm9io08hJWVnlB+KdK5lBi5M2R9ihfDBU+vtc2yWsSOnuyJcnDCfu92Clb5F1zIghvSOR1PhnzDZHGffX5I9nBe+csWVoXEP2E84YIVtSqRhP2pqYplD2I09W+0zzkdHMrrnaSUOGaUoWqyFbHRx7QcvlE63255/hc34toq6boOB3Io4jpBniQgOCkwgdiqThr8pSEqKaHurkYBdaC3CpuXQSeWssoThlml9u8SMdC0yarNohWP6M5yF8JUF1KspySa3Va7K185rQuvxF+t25XwWR8bY9gACoZhN2QLBwcQ9Vm74KCl674QGfroGzvga/zlX4IEwYzGoEZywhSmdoOZfjrl8QZ+kXROGZV9CtC+4MuUNs616If5NRdNYujswxXx/aGpQDWXd6ONrVBtSRpqPb6FMvuBtnpG2a8juwlMiMD7emvhyIFOVZQO0HLlZuZuWiDVDPmS6KvY2vuZubC+/ZVqiEcgtuy5tQIxAEYn57SaRiT2DUdGMg7jLFuPOjLm4RodrY+KmgsHagpjWU8RzH9Pi6uB8JNXNREKRgij+qzTQyJHmpVS/dArlpd6uEWutud44/+kOmc3pNEDnkO0WMsk+1VloHjeLX7bWpKqN/c75ZhtHCsILhgm6ApD/bQzsGS3TmtuZuNYqApcd94MFmfwtfJTWqDz+hlkScPWh3L1eH4DT6uarENPsRyi3lMU1YC6y+B3TON05ExmIXVhYWDwkYUBCOtTAyKfj53vS3EYK3Bj14lqiX4Jtvm4P/x749ff37+7jf8f9ve/gOjg8fz
Steps to reproduce
在demo中无法复现这一问题 代码和我本地相同
环境vite 4.3.9 @vitejs/plugin-vue-jsx
在我本地中如果这里使用解构亦或者是lodash deepClone方法后 只要触发热更新就无限执行setup的所有逻辑
如果直接使用当前变量 是正常的
What is expected?
请帮我排查一下 是否是我的写法有问题 还是某些隐藏的bug
What is actually happening?
只要修改案例中 test1Child.vue 的组件 就会触发无限循环整个setup

这是我本地的报错
System Info
Any additional comments?
No response
Beta Was this translation helpful? Give feedback.
All reactions