Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-intersection-observer-hook

Package Overview
Dependencies
Maintainers
1
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-intersection-observer-hook - npm Package Compare versions

Comparing version 0.1.0-alpha.0 to 0.1.0-alpha.1

7

dist/index.d.ts

@@ -1,5 +0,6 @@

declare type RefCallbackInput = Element | null;
declare function useIntersectionObserver({ root, rootMargin, threshold, }?: IntersectionObserverInit): [(node: RefCallbackInput) => void, {
isIntersecting: boolean;
declare type IntersectionObserverHookRefCallbackNode = Element | null;
declare type IntersectionObserverHookResult = [(node: IntersectionObserverHookRefCallbackNode) => void, {
entry: IntersectionObserverEntry | undefined;
}];
declare function useIntersectionObserver({ root, rootMargin, threshold, }?: IntersectionObserverInit): IntersectionObserverHookResult;
export default useIntersectionObserver;

@@ -16,5 +16,5 @@ 'use strict';

var _useState = react.useState(false),
isIntersecting = _useState[0],
setIsIntersecting = _useState[1];
var _useState = react.useState(),
entry = _useState[0],
setEntry = _useState[1];

@@ -37,3 +37,3 @@ react.useEffect(function () {

var entry = _ref2[0];
setIsIntersecting(entry.isIntersecting);
setEntry(entry);
}, {

@@ -56,5 +56,8 @@ root: root,

}, [root, rootMargin, threshold]);
return [refCallback, {
isIntersecting: isIntersecting
}];
var result = react.useMemo(function () {
return [refCallback, {
entry: entry
}];
}, [refCallback, entry]);
return result;
}

@@ -61,0 +64,0 @@

@@ -1,2 +0,2 @@

"use strict";var r=require("react");exports.default=function(e){var t=void 0===e?{}:e,n=t.root,o=void 0===n?null:n,c=t.rootMargin,i=void 0===c?"0px":c,u=t.threshold,s=void 0===u?[0]:u,a=r.useRef(),v=r.useState(!1),d=v[0],f=v[1];return r.useEffect((function(){return function(){var r=a.current;r&&r.disconnect()}}),[]),[r.useCallback((function(r){var e=(a.current||(a.current=new IntersectionObserver((function(r){f(r[0].isIntersecting)}),{root:o,rootMargin:i,threshold:s})),a.current);e.disconnect(),r&&e.observe(r)}),[o,i,s]),{isIntersecting:d}]};
"use strict";var r=require("react");exports.default=function(e){var t=void 0===e?{}:e,n=t.root,o=void 0===n?null:n,u=t.rootMargin,c=void 0===u?"0px":u,i=t.threshold,s=void 0===i?[0]:i,a=r.useRef(),v=r.useState(),f=v[0],d=v[1];r.useEffect((function(){return function(){var r=a.current;r&&r.disconnect()}}),[]);var l=r.useCallback((function(r){var e=(a.current||(a.current=new IntersectionObserver((function(r){d(r[0])}),{root:o,rootMargin:c,threshold:s})),a.current);e.disconnect(),r&&e.observe(r)}),[o,c,s]);return r.useMemo((function(){return[l,{entry:f}]}),[l,f])};
//# sourceMappingURL=react-intersection-observer-hook.cjs.production.min.js.map

@@ -1,2 +0,2 @@

import { useRef, useState, useEffect, useCallback } from 'react';
import { useRef, useState, useEffect, useCallback, useMemo } from 'react';

@@ -14,5 +14,5 @@ function useIntersectionObserver(_temp) {

var _useState = useState(false),
isIntersecting = _useState[0],
setIsIntersecting = _useState[1];
var _useState = useState(),
entry = _useState[0],
setEntry = _useState[1];

@@ -35,3 +35,3 @@ useEffect(function () {

var entry = _ref2[0];
setIsIntersecting(entry.isIntersecting);
setEntry(entry);
}, {

@@ -54,5 +54,8 @@ root: root,

}, [root, rootMargin, threshold]);
return [refCallback, {
isIntersecting: isIntersecting
}];
var result = useMemo(function () {
return [refCallback, {
entry: entry
}];
}, [refCallback, entry]);
return result;
}

@@ -59,0 +62,0 @@

{
"name": "react-intersection-observer-hook",
"version": "0.1.0-alpha.0",
"version": "0.1.0-alpha.1",
"license": "MIT",

@@ -5,0 +5,0 @@ "author": "onderonur",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc