kopia lustrzana https://gitlab.com/soapbox-pub/soapbox
				
				
				
			Merge branch 'fix-use-on-screen-hook' into 'next'
Make sure the current element is present before execution See merge request soapbox-pub/soapbox-fe!1141virtualized-window
						commit
						76b72d9364
					
				| 
						 | 
				
			
			@ -8,12 +8,14 @@ export const useOnScreen = (ref: React.MutableRefObject<HTMLElement>) =>  {
 | 
			
		|||
  );
 | 
			
		||||
 | 
			
		||||
  React.useEffect(() => {
 | 
			
		||||
    observer.observe(ref.current);
 | 
			
		||||
    if (ref.current) {
 | 
			
		||||
      observer.observe(ref.current);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    return () => {
 | 
			
		||||
      observer.disconnect();
 | 
			
		||||
    };
 | 
			
		||||
  }, []);
 | 
			
		||||
  }, [ref.current]);
 | 
			
		||||
 | 
			
		||||
  return isIntersecting;
 | 
			
		||||
};
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Ładowanie…
	
		Reference in New Issue