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

@react-hook/event

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@react-hook/event - npm Package Compare versions

Comparing version 1.2.1 to 1.2.2

23

dist/main/index.js

@@ -12,27 +12,26 @@ "use strict";

function useEvent(target, type, listener, cleanup = noop) {
function useEvent(target, type, listener, cleanup) {
const storedListener = (0, _latest.default)(listener);
const storedCleanup = (0, _latest.default)(cleanup);
function _ref(...args) {
storedListener.current.apply(this, args);
}
(0, _passiveLayoutEffect.default)(() => {
const targetEl = target && 'current' in target ? target.current : target;
if (!targetEl) return;
const listener = _ref;
let didUnsubscribe = 0;
function listener(...args) {
if (didUnsubscribe) return;
storedListener.current.apply(this, args);
}
targetEl.addEventListener(type, listener);
const cleanup = storedCleanup.current;
return () => {
didUnsubscribe = 1;
targetEl.removeEventListener(type, listener);
cleanup();
cleanup && cleanup();
}; // eslint-disable-next-line react-hooks/exhaustive-deps
}, [target, type]);
} // eslint-disable-next-line @typescript-eslint/no-empty-function
}
function noop() {}
var _default = useEvent;
exports.default = _default;
import useLayoutEffect from '@react-hook/passive-layout-effect';
import useLatest from '@react-hook/latest';
function useEvent(target, type, listener, cleanup = noop) {
function useEvent(target, type, listener, cleanup) {
const storedListener = useLatest(listener);
const storedCleanup = useLatest(cleanup);
function _ref(...args) {
storedListener.current.apply(this, args);
}
useLayoutEffect(() => {
const targetEl = target && 'current' in target ? target.current : target;
if (!targetEl) return;
const listener = _ref;
let didUnsubscribe = 0;
function listener(...args) {
if (didUnsubscribe) return;
storedListener.current.apply(this, args);
}
targetEl.addEventListener(type, listener);
const cleanup = storedCleanup.current;
return () => {
didUnsubscribe = 1;
targetEl.removeEventListener(type, listener);
cleanup();
cleanup && cleanup();
}; // eslint-disable-next-line react-hooks/exhaustive-deps
}, [target, type]);
} // eslint-disable-next-line @typescript-eslint/no-empty-function
}
function noop() {}
export default useEvent;

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

!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n(require("react")):"function"==typeof define&&define.amd?define(["react"],n):(e=e||self).useEvent=n(e.React)}(this,(function(e){"use strict";function n(){}var t=e["undefined"!=typeof document&&void 0!==document.createElement?"useLayoutEffect":"useEffect"],r=function(n){var t=e.useRef(n);return t.current=n,t};return function(e,u,f,o){function c(){for(var e=arguments.length,n=new Array(e),t=0;e>t;t++)n[t]=arguments[t];i.current.apply(this,n)}void 0===o&&(o=n);var i=r(f),a=r(o);t((function(){var n=e&&"current"in e?e.current:e;if(n){var t=c;n.addEventListener(u,t);var r=a.current;return function(){n.removeEventListener(u,t),r()}}}),[e,u])}}));
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("react")):"function"==typeof define&&define.amd?define(["react"],t):(e=e||self).useEvent=t(e.React)}(this,(function(e){"use strict";var t=e["undefined"!=typeof document&&void 0!==document.createElement?"useLayoutEffect":"useEffect"],n=function(t){var n=e.useRef(t);return n.current=t,n};return function(e,r,u,f){var c=n(u),i=n(f);t((function(){function t(){if(!u){for(var e=arguments.length,t=new Array(e),n=0;e>n;n++)t[n]=arguments[n];c.current.apply(this,t)}}var n=e&&"current"in e?e.current:e;if(n){var u=0;n.addEventListener(r,t);var f=i.current;return function(){u=1,n.removeEventListener(r,t),f&&f()}}}),[e,r])}}));
//# sourceMappingURL=use-event.js.map
{
"name": "@react-hook/event",
"version": "1.2.1",
"version": "1.2.2",
"homepage": "https://github.com/jaredLunde/react-hook/tree/master/packages/event#readme",

@@ -5,0 +5,0 @@ "repository": "github:jaredLunde/react-hook",

@@ -15,10 +15,5 @@ <hr>

</a>
<!--
<a aria-label="Code coverage report" href="https://codecov.io/gh/jaredLunde/react-hook">
<img alt="Code coverage" src="https://img.shields.io/codecov/c/gh/jaredLunde/react-hook?style=for-the-badge&labelColor=24292e">
</a>
<a aria-label="Build status" href="https://travis-ci.com/jaredLunde/react-hook">
<img alt="Build status" src="https://img.shields.io/travis/com/jaredLunde/react-hook?style=for-the-badge&labelColor=24292e">
</a>
-->
<a aria-label="NPM version" href="https://www.npmjs.com/package/@react-hook/event">

@@ -25,0 +20,0 @@ <img alt="NPM Version" src="https://img.shields.io/npm/v/@react-hook/event?style=for-the-badge&labelColor=24292e">

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

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