下面的几行代码,如果写在Profiler组件里面会有什么不一样呢?
来源:13-4 用React.Profiler追踪性能信息

diaojiulishifei
2021-06-22
let queue: unknown[] = []; const sendProfilerQueue = () => { if (!queue.length) { return; } const queueToSend = [...queue]; queue = []; console.log(queueToSend); }; setInterval(sendProfilerQueue, 5000);
写回答
1回答
-
Nolan
2021-06-25
如果直接写在组件里 queue 会在每次渲染的时候都被重新定义成空数组
012021-06-25
相似问题