usehooks-ts
Advanced tools
Comparing version 2.2.0 to 2.2.1
import { RefObject } from 'react'; | ||
declare function useEventListener<T extends HTMLElement = HTMLDivElement>(eventName: keyof WindowEventMap | string, handler: (event: Event) => void, element?: RefObject<T>): void; | ||
declare function useEventListener<K extends keyof WindowEventMap>(eventName: K, handler: (event: WindowEventMap[K]) => void): void; | ||
declare function useEventListener<K extends keyof HTMLElementEventMap, T extends HTMLElement = HTMLDivElement>(eventName: K, handler: (event: HTMLElementEventMap[K]) => void, element: RefObject<T>): void; | ||
export default useEventListener; | ||
//# sourceMappingURL=useEventListener.d.ts.map |
import { Dispatch, SetStateAction } from 'react'; | ||
declare global { | ||
interface WindowEventMap { | ||
'local-storage': CustomEvent; | ||
} | ||
} | ||
declare type SetValue<T> = Dispatch<SetStateAction<T>>; | ||
@@ -3,0 +8,0 @@ declare function useLocalStorage<T>(key: string, initialValue: T): [T, SetValue<T>]; |
@@ -15,3 +15,3 @@ "use strict"; | ||
catch (error) { | ||
console.warn("Error reading localStorage key \u201C" + key + "\u201D:", error); | ||
console.warn("Error reading localStorage key \u201C".concat(key, "\u201D:"), error); | ||
return initialValue; | ||
@@ -23,3 +23,3 @@ } | ||
if (typeof window == 'undefined') { | ||
console.warn("Tried setting localStorage key \u201C" + key + "\u201D even though environment is not a client"); | ||
console.warn("Tried setting localStorage key \u201C".concat(key, "\u201D even though environment is not a client")); | ||
} | ||
@@ -33,3 +33,3 @@ try { | ||
catch (error) { | ||
console.warn("Error setting localStorage key \u201C" + key + "\u201D:", error); | ||
console.warn("Error setting localStorage key \u201C".concat(key, "\u201D:"), error); | ||
} | ||
@@ -36,0 +36,0 @@ }; |
@@ -17,3 +17,3 @@ "use strict"; | ||
if (scrollBarWidth) { | ||
document.body.style.paddingRight = scrollBarWidth + "px"; | ||
document.body.style.paddingRight = "".concat(scrollBarWidth, "px"); | ||
} | ||
@@ -20,0 +20,0 @@ return function () { |
@@ -15,3 +15,3 @@ "use strict"; | ||
catch (error) { | ||
console.warn("Error reading localStorage key \u201C" + key + "\u201D:", error); | ||
console.warn("Error reading localStorage key \u201C".concat(key, "\u201D:"), error); | ||
return null; | ||
@@ -18,0 +18,0 @@ } |
@@ -11,3 +11,3 @@ "use strict"; | ||
} | ||
var script = document.querySelector("script[src=\"" + src + "\"]"); | ||
var script = document.querySelector("script[src=\"".concat(src, "\"]")); | ||
if (!script) { | ||
@@ -14,0 +14,0 @@ script = document.createElement('script'); |
import { RefObject } from 'react'; | ||
declare function useEventListener<T extends HTMLElement = HTMLDivElement>(eventName: keyof WindowEventMap | string, handler: (event: Event) => void, element?: RefObject<T>): void; | ||
declare function useEventListener<K extends keyof WindowEventMap>(eventName: K, handler: (event: WindowEventMap[K]) => void): void; | ||
declare function useEventListener<K extends keyof HTMLElementEventMap, T extends HTMLElement = HTMLDivElement>(eventName: K, handler: (event: HTMLElementEventMap[K]) => void, element: RefObject<T>): void; | ||
export default useEventListener; | ||
//# sourceMappingURL=useEventListener.d.ts.map |
import { Dispatch, SetStateAction } from 'react'; | ||
declare global { | ||
interface WindowEventMap { | ||
'local-storage': CustomEvent; | ||
} | ||
} | ||
declare type SetValue<T> = Dispatch<SetStateAction<T>>; | ||
@@ -3,0 +8,0 @@ declare function useLocalStorage<T>(key: string, initialValue: T): [T, SetValue<T>]; |
@@ -13,3 +13,3 @@ import { useEffect, useState } from 'react'; | ||
catch (error) { | ||
console.warn("Error reading localStorage key \u201C" + key + "\u201D:", error); | ||
console.warn("Error reading localStorage key \u201C".concat(key, "\u201D:"), error); | ||
return initialValue; | ||
@@ -21,3 +21,3 @@ } | ||
if (typeof window == 'undefined') { | ||
console.warn("Tried setting localStorage key \u201C" + key + "\u201D even though environment is not a client"); | ||
console.warn("Tried setting localStorage key \u201C".concat(key, "\u201D even though environment is not a client")); | ||
} | ||
@@ -31,3 +31,3 @@ try { | ||
catch (error) { | ||
console.warn("Error setting localStorage key \u201C" + key + "\u201D:", error); | ||
console.warn("Error setting localStorage key \u201C".concat(key, "\u201D:"), error); | ||
} | ||
@@ -34,0 +34,0 @@ }; |
@@ -15,3 +15,3 @@ import { useEffect, useLayoutEffect, useState } from 'react'; | ||
if (scrollBarWidth) { | ||
document.body.style.paddingRight = scrollBarWidth + "px"; | ||
document.body.style.paddingRight = "".concat(scrollBarWidth, "px"); | ||
} | ||
@@ -18,0 +18,0 @@ return function () { |
@@ -13,3 +13,3 @@ import { useEffect, useState } from 'react'; | ||
catch (error) { | ||
console.warn("Error reading localStorage key \u201C" + key + "\u201D:", error); | ||
console.warn("Error reading localStorage key \u201C".concat(key, "\u201D:"), error); | ||
return null; | ||
@@ -16,0 +16,0 @@ } |
@@ -9,3 +9,3 @@ import { useEffect, useState } from 'react'; | ||
} | ||
var script = document.querySelector("script[src=\"" + src + "\"]"); | ||
var script = document.querySelector("script[src=\"".concat(src, "\"]")); | ||
if (!script) { | ||
@@ -12,0 +12,0 @@ script = document.createElement('script'); |
@@ -5,3 +5,3 @@ { | ||
"description": "React hook library, ready to use, written in Typescript.", | ||
"version": "2.2.0", | ||
"version": "2.2.1", | ||
"author": "Julien CARON <juliencaron@protonmail.com>", | ||
@@ -31,4 +31,3 @@ "homepage": "https://usehooks-ts.com", | ||
"clean": "rimraf -rf ./dist ./esm", | ||
"types-check": "tsc -p tsconfig.json", | ||
"upgrade-interactive": "npm-check --update" | ||
"types-check": "tsc -p tsconfig.json" | ||
}, | ||
@@ -38,3 +37,2 @@ "devDependencies": { | ||
"chokidar-cli": "^3.0.0", | ||
"npm-check": "^5.9.2", | ||
"react": ">=16.8.0", | ||
@@ -55,3 +53,3 @@ "react-test-renderer": ">=16.8.0", | ||
}, | ||
"gitHead": "0568a5cb7789c4fe45c606a79688a238ab47af43" | ||
"gitHead": "7c20fdd05fcaf273ce04d2a99d7db965231bc2a8" | ||
} |
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
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
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
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
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
232039
6
2775