From 7373fbf0a6e0f320f031675865eedb03c82948b2 Mon Sep 17 00:00:00 2001 From: Nancy <3510671794@qq.com> Date: Mon, 4 Nov 2024 20:13:34 +0800 Subject: [PATCH] export-button-throttle-debounce --- app/page.tsx | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/app/page.tsx b/app/page.tsx index 1b97d9a..c6cf121 100644 --- a/app/page.tsx +++ b/app/page.tsx @@ -55,13 +55,12 @@ function ExportButton({ setHtml }: { setHtml: (html: string) => void }) { const editor = useEditor(); const [loading, setLoading] = useState(false); - const throttle = (func: () => void, limit: number) => { + const throttle = (func: (...args: any[]) => void, limit: number) => { let lastFunc: NodeJS.Timeout | null = null; let lastRan: number | null = null; - return function () { + return function (this: any, ...args: any[]) { const context = this; - const args = arguments; if (lastRan === null || Date.now() - lastRan >= limit) { func.apply(context, args);