1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-01-02 12:47:41 +02:00
joplin/ElectronClient/gui/ResizableLayout/hooks/useWindowResizeEvent.ts
2020-09-15 14:01:07 +01:00

18 lines
419 B
TypeScript

import { useEffect } from 'react';
const debounce = require('debounce');
export default function useWindowResizeEvent(eventEmitter:any) {
useEffect(() => {
const window_resize = debounce(() => {
eventEmitter.current.emit('resize');
}, 500);
window.addEventListener('resize', window_resize);
return () => {
window_resize.clear();
window.removeEventListener('resize', window_resize);
};
}, []);
}