fix: debounce ref (#26433)

This commit is contained in:
crazywoola 2025-09-29 16:13:38 +08:00 committed by GitHub
parent c43c72c1a3
commit fd86cadf67
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -160,8 +160,13 @@ const Chat: FC<ChatProps> = ({
})
useEffect(() => {
window.addEventListener('resize', debounce(handleWindowResize))
return () => window.removeEventListener('resize', handleWindowResize)
const debouncedHandler = debounce(handleWindowResize, 200)
window.addEventListener('resize', debouncedHandler)
return () => {
window.removeEventListener('resize', debouncedHandler)
debouncedHandler.cancel()
}
}, [handleWindowResize])
useEffect(() => {