Add backend and frontend
This commit is contained in:
16
frontend/src/utils/resize-hook.ts
Normal file
16
frontend/src/utils/resize-hook.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
import React from 'react';
|
||||
|
||||
export const useResize = <T extends HTMLElement = HTMLElement>(
|
||||
onResize: () => void,
|
||||
) => {
|
||||
const ref = React.useRef<T>(null);
|
||||
React.useEffect(() => {
|
||||
if (ref.current) {
|
||||
const observer = new ResizeObserver(onResize);
|
||||
observer.observe(ref.current);
|
||||
return () => observer.disconnect();
|
||||
}
|
||||
return () => undefined;
|
||||
}, [ref.current]);
|
||||
return ref;
|
||||
};
|
||||
Reference in New Issue
Block a user