mirror of
https://github.com/towfiqi/serpbear
synced 2025-06-26 18:15:54 +00:00
- Replaces useEffet with useMemo & useLayoutEffect where necessary. - Converts some useEffects to separate hooks. - Moves the functions defined within components to utils. - Splits the Keywords renderPosition function to its own component.
14 lines
321 B
TypeScript
14 lines
321 B
TypeScript
import { useEffect } from 'react';
|
|
|
|
const useWindowResize = (onResize: () => void) => {
|
|
useEffect(() => {
|
|
onResize();
|
|
window.addEventListener('resize', onResize);
|
|
return () => {
|
|
window.removeEventListener('resize', onResize);
|
|
};
|
|
}, [onResize]);
|
|
};
|
|
|
|
export default useWindowResize;
|