🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
DemoInstallSign in
Socket

@fremtind/jkl-react-hooks

Package Overview
Dependencies
Maintainers
3
Versions
226
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@fremtind/jkl-react-hooks - npm Package Compare versions

Comparing version

to
12.3.0

13

build/cjs/useLocalStorage/useLocalStorage.js

@@ -34,7 +34,10 @@ "use strict";

const updateState = (0, import_react.useCallback)(
(newValue) => {
setState(newValue);
if (typeof window !== "undefined" && localStorage) {
localStorage.setItem(key, JSON.stringify(newValue));
}
(setStateAction) => {
setState((previousValue) => {
const newValue = typeof setStateAction === "function" ? setStateAction(previousValue) : setStateAction;
if (typeof window !== "undefined" && localStorage) {
localStorage.setItem(key, JSON.stringify(newValue));
}
return newValue;
});
},

@@ -41,0 +44,0 @@ [key]

@@ -11,7 +11,10 @@ import { useCallback, useState } from "react";

const updateState = useCallback(
(newValue) => {
setState(newValue);
if (typeof window !== "undefined" && localStorage) {
localStorage.setItem(key, JSON.stringify(newValue));
}
(setStateAction) => {
setState((previousValue) => {
const newValue = typeof setStateAction === "function" ? setStateAction(previousValue) : setStateAction;
if (typeof window !== "undefined" && localStorage) {
localStorage.setItem(key, JSON.stringify(newValue));
}
return newValue;
});
},

@@ -18,0 +21,0 @@ [key]

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

export declare const useLocalStorage: <T>(key: string, defaultValue: T) => [T, (newValue: T) => void];
export declare const useLocalStorage: <T>(key: string, defaultValue: T) => [T, React.Dispatch<React.SetStateAction<T>>];
{
"name": "@fremtind/jkl-react-hooks",
"version": "12.2.20",
"version": "12.3.0",
"publishConfig": {

@@ -57,3 +57,3 @@ "access": "public"

},
"gitHead": "7f500c4616902d7be29ebcb80abb1cedc96b14f3"
"gitHead": "75278c5ff95c8ed3c51bae7611ef7586a20d558f"
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet