@react-hook/event
Advanced tools
Comparing version 1.2.2 to 1.2.3
@@ -6,12 +6,20 @@ "use strict"; | ||
var React = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("react")); | ||
var _passiveLayoutEffect = /*#__PURE__*/_interopRequireDefault( /*#__PURE__*/require("@react-hook/passive-layout-effect")); | ||
var _latest = /*#__PURE__*/_interopRequireDefault( /*#__PURE__*/require("@react-hook/latest")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; } | ||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } | ||
function useEvent(target, type, listener, cleanup) { | ||
const storedListener = (0, _latest.default)(listener); | ||
const storedCleanup = (0, _latest.default)(cleanup); | ||
const storedListener = React.useRef(listener); | ||
const storedCleanup = React.useRef(cleanup); | ||
(0, _passiveLayoutEffect.default)(() => { | ||
storedListener.current = listener; | ||
storedCleanup.current = cleanup; | ||
}); | ||
(0, _passiveLayoutEffect.default)(() => { | ||
const targetEl = target && 'current' in target ? target.current : target; | ||
@@ -18,0 +26,0 @@ if (!targetEl) return; |
@@ -0,8 +1,12 @@ | ||
import * as React from 'react'; | ||
import useLayoutEffect from '@react-hook/passive-layout-effect'; | ||
import useLatest from '@react-hook/latest'; | ||
function useEvent(target, type, listener, cleanup) { | ||
const storedListener = useLatest(listener); | ||
const storedCleanup = useLatest(cleanup); | ||
const storedListener = React.useRef(listener); | ||
const storedCleanup = React.useRef(cleanup); | ||
useLayoutEffect(() => { | ||
storedListener.current = listener; | ||
storedCleanup.current = cleanup; | ||
}); | ||
useLayoutEffect(() => { | ||
const targetEl = target && 'current' in target ? target.current : target; | ||
@@ -9,0 +13,0 @@ if (!targetEl) return; |
@@ -1,2 +0,2 @@ | ||
!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])}})); | ||
!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"];return function(n,r,u,f){var c=e.useRef(u),i=e.useRef(f);t((function(){c.current=u,i.current=f})),t((function(){function e(){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 t=n&&"current"in n?n.current:n;if(t){var u=0;t.addEventListener(r,e);var f=i.current;return function(){u=1,t.removeEventListener(r,e),f&&f()}}}),[n,r])}})); | ||
//# sourceMappingURL=use-event.js.map |
{ | ||
"name": "@react-hook/event", | ||
"version": "1.2.2", | ||
"version": "1.2.3", | ||
"homepage": "https://github.com/jaredLunde/react-hook/tree/master/packages/event#readme", | ||
@@ -122,3 +122,3 @@ "repository": "github:jaredLunde/react-hook", | ||
"lint-staged": "latest", | ||
"lundle": "latest", | ||
"lundle": "^0.4.9", | ||
"prettier": "latest", | ||
@@ -131,3 +131,2 @@ "react": "latest", | ||
"dependencies": { | ||
"@react-hook/latest": "^1.0.2", | ||
"@react-hook/passive-layout-effect": "^1.2.0" | ||
@@ -134,0 +133,0 @@ }, |
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
35502
2
16
301
- Removed@react-hook/latest@^1.0.2
- Removed@react-hook/latest@1.0.3(transitive)