Dynamically truncate the Account's name/username in hidden content See merge request soapbox-pub/soapbox-fe!1132virtualized-window
commit
a3718d6f23
@ -1 +1,2 @@
|
||||
export { useAppSelector } from './useAppSelector';
|
||||
export { useOnScreen } from './useOnScreen';
|
||||
|
@ -0,0 +1,19 @@
|
||||
import * as React from 'react';
|
||||
|
||||
export const useOnScreen = (ref: React.MutableRefObject<HTMLElement>) => {
|
||||
const [isIntersecting, setIntersecting] = React.useState(false);
|
||||
|
||||
const observer = new IntersectionObserver(
|
||||
([entry]) => setIntersecting(entry.isIntersecting),
|
||||
);
|
||||
|
||||
React.useEffect(() => {
|
||||
observer.observe(ref.current);
|
||||
|
||||
return () => {
|
||||
observer.disconnect();
|
||||
};
|
||||
}, []);
|
||||
|
||||
return isIntersecting;
|
||||
};
|
Loading…
Reference in new issue