fix: debounce ref (#26433)
This commit is contained in:
parent
c43c72c1a3
commit
fd86cadf67
1 changed files with 7 additions and 2 deletions
|
|
@ -160,8 +160,13 @@ const Chat: FC<ChatProps> = ({
|
||||||
})
|
})
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
window.addEventListener('resize', debounce(handleWindowResize))
|
const debouncedHandler = debounce(handleWindowResize, 200)
|
||||||
return () => window.removeEventListener('resize', handleWindowResize)
|
window.addEventListener('resize', debouncedHandler)
|
||||||
|
|
||||||
|
return () => {
|
||||||
|
window.removeEventListener('resize', debouncedHandler)
|
||||||
|
debouncedHandler.cancel()
|
||||||
|
}
|
||||||
}, [handleWindowResize])
|
}, [handleWindowResize])
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue