Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

Rev 5188 | Rev 5196 | Ir a la última revisión | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 5188 Rev 5193
Línea 1... Línea 1...
1
import { useEffect, useState } from 'react'
1
import { useEffect, useState } from 'react'
Línea 2... Línea 2...
2
 
2
 
3
const useNear = (ref, rootMargin = '0px') => {
-
 
4
  // State and setter for storing whether element is visible
3
const useNear = (ref, rootMargin = '0px') => {
Línea 5... Línea 4...
5
  const [isIntersecting, setIntersecting] = useState(false)
4
  const [isIntersecting, setIntersecting] = useState(false)
Línea 6... Línea 5...
6
 
5
 
Línea 20... Línea 19...
20
      observer.observe(ref.current)
19
      observer.observe(ref.current)
21
    }
20
    }
22
    return () => {
21
    return () => {
23
      observer.unobserve(ref.current)
22
      observer.unobserve(ref.current)
24
    }
23
    }
25
  }, []) // Empty array ensures that effect is only run on mount and unmount
24
  }, [isIntersecting]) // Empty array ensures that effect is only run on mount and unmount
Línea 26... Línea 25...
26
 
25
 
27
  return [isIntersecting, reset]
26
  return [isIntersecting, reset]
Línea 28... Línea 27...
28
}
27
}