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

@react-hookz/web

Package Overview
Dependencies
Maintainers
2
Versions
128
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@react-hookz/web - npm Package Compare versions

Comparing version 3.6.0 to 3.7.0

7

CHANGELOG.md

@@ -0,1 +1,8 @@

# [3.7.0](https://github.com/react-hookz/web/compare/v3.6.0...v3.7.0) (2021-07-03)
### Features
* improve `useEventListener` ([#169](https://github.com/react-hookz/web/issues/169)) ([d016ea9](https://github.com/react-hookz/web/commit/d016ea9f0d1ab42712695e886c2b3794fdb629de))
# [3.6.0](https://github.com/react-hookz/web/compare/v3.5.0...v3.6.0) (2021-07-03)

@@ -2,0 +9,0 @@

6

cjs/useEventListener/useEventListener.d.ts

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

import { MutableRefObject, RefObject } from 'react';
declare type ITargetOrTargetRef<T extends EventTarget> = T | null | RefObject<T> | MutableRefObject<T>;
import { RefObject } from 'react';
/**

@@ -11,3 +10,2 @@ * Subscribes an event listener to the target, and automatically unsubscribes

*/
export declare function useEventListener<T extends EventTarget>(target: ITargetOrTargetRef<T>, ...params: Parameters<T['addEventListener']> | [string, EventListenerOrEventListenerObject | ((...args: any[]) => any), ...any]): void;
export {};
export declare function useEventListener<T extends EventTarget>(target: RefObject<T> | T | null, ...params: Parameters<T['addEventListener']> | [string, EventListenerOrEventListenerObject | ((...args: any[]) => any), ...any]): void;

@@ -11,4 +11,4 @@ "use strict";

var react_1 = require("react");
var __1 = require("..");
var misc_1 = require("../util/misc");
var __1 = require("..");
/**

@@ -27,6 +27,2 @@ * Subscribes an event listener to the target, and automatically unsubscribes

}
// extract current target from ref object
var tgt = target && misc_1.hasOwnProperty(target, 'current')
? target.current
: target;
var isMounted = __1.useIsMounted();

@@ -63,2 +59,3 @@ // create static event listener

react_1.useEffect(function () {
var tgt = target && misc_1.hasOwnProperty(target, 'current') ? target.current : target;
if (!tgt)

@@ -70,4 +67,4 @@ return undefined;

// eslint-disable-next-line react-hooks/exhaustive-deps
}, [tgt, params[0]]);
}, [target, params[0]]);
}
exports.useEventListener = useEventListener;

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

import { MutableRefObject, RefObject } from 'react';
declare type ITargetOrTargetRef<T extends EventTarget> = T | null | RefObject<T> | MutableRefObject<T>;
import { RefObject } from 'react';
/**

@@ -11,3 +10,2 @@ * Subscribes an event listener to the target, and automatically unsubscribes

*/
export declare function useEventListener<T extends EventTarget>(target: ITargetOrTargetRef<T>, ...params: Parameters<T['addEventListener']> | [string, EventListenerOrEventListenerObject | ((...args: any[]) => any), ...any]): void;
export {};
export declare function useEventListener<T extends EventTarget>(target: RefObject<T> | T | null, ...params: Parameters<T['addEventListener']> | [string, EventListenerOrEventListenerObject | ((...args: any[]) => any), ...any]): void;

@@ -8,4 +8,4 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from) {

import { useEffect, useMemo } from 'react';
import { useIsMounted, useSyncedRef } from '..';
import { hasOwnProperty } from "../util/misc.js";
import { useSyncedRef, useIsMounted } from '..';
/**

@@ -24,6 +24,2 @@ * Subscribes an event listener to the target, and automatically unsubscribes

}
// extract current target from ref object
var tgt = target && hasOwnProperty(target, 'current')
? target.current
: target;
var isMounted = useIsMounted();

@@ -60,2 +56,3 @@ // create static event listener

useEffect(function () {
var tgt = target && hasOwnProperty(target, 'current') ? target.current : target;
if (!tgt)

@@ -67,3 +64,3 @@ return undefined;

// eslint-disable-next-line react-hooks/exhaustive-deps
}, [tgt, params[0]]);
}, [target, params[0]]);
}

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

import { MutableRefObject, RefObject } from 'react';
declare type ITargetOrTargetRef<T extends EventTarget> = T | null | RefObject<T> | MutableRefObject<T>;
import { RefObject } from 'react';
/**

@@ -11,3 +10,2 @@ * Subscribes an event listener to the target, and automatically unsubscribes

*/
export declare function useEventListener<T extends EventTarget>(target: ITargetOrTargetRef<T>, ...params: Parameters<T['addEventListener']> | [string, EventListenerOrEventListenerObject | ((...args: any[]) => any), ...any]): void;
export {};
export declare function useEventListener<T extends EventTarget>(target: RefObject<T> | T | null, ...params: Parameters<T['addEventListener']> | [string, EventListenerOrEventListenerObject | ((...args: any[]) => any), ...any]): void;
/* eslint-disable @typescript-eslint/no-explicit-any */
import { useEffect, useMemo } from 'react';
import { useIsMounted, useSyncedRef } from '..';
import { hasOwnProperty } from "../util/misc.js";
import { useSyncedRef, useIsMounted } from '..';
/**

@@ -14,6 +14,2 @@ * Subscribes an event listener to the target, and automatically unsubscribes

export function useEventListener(target, ...params) {
// extract current target from ref object
const tgt = target && hasOwnProperty(target, 'current')
? target.current
: target;
const isMounted = useIsMounted();

@@ -45,2 +41,3 @@ // create static event listener

useEffect(() => {
const tgt = target && hasOwnProperty(target, 'current') ? target.current : target;
if (!tgt)

@@ -52,3 +49,3 @@ return undefined;

// eslint-disable-next-line react-hooks/exhaustive-deps
}, [tgt, params[0]]);
}, [target, params[0]]);
}
{
"name": "@react-hookz/web",
"version": "3.6.0",
"version": "3.7.0",
"description": "React hooks done right, for browser and SSR.",

@@ -5,0 +5,0 @@ "keywords": [

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