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

@devboldly/react-use-window-global

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@devboldly/react-use-window-global - npm Package Compare versions

Comparing version 0.0.1 to 0.0.2

10

dist/hooks/useWindowGlobal.d.ts
/** */
export declare function useWindowGlobal<T>(keyName: string, defaultValue?: T | undefined, namespace?: string): ExampleHook<T>;
export declare type ExampleHook<T> = [T | undefined, (value: T | undefined) => void, () => void, () => void];
export declare function useWindowGlobal<T>(keyName: string, defaultValue?: T | undefined, namespace?: string): WindowGlobalHook<T>;
export declare type WindowGlobalHook<T> = {
value: T | undefined;
setValue: (value: T | undefined) => void;
loaded: boolean;
reset: () => void;
restore: () => void;
};

10

dist/hooks/useWindowGlobal.js

@@ -16,3 +16,3 @@ "use strict";

if (defaultValue === void 0) { defaultValue = undefined; }
var _a = React.useState(true), firstRender = _a[0], setFirstRender = _a[1];
var _a = React.useState(false), loaded = _a[0], setLoaded = _a[1];
var _b = React.useState(false), shouldRestore = _b[0], setShouldRestore = _b[1];

@@ -33,4 +33,3 @@ var _c = React.useState(defaultValue), reactState = _c[0], setReactState = _c[1];

// Synchronize value with window on first render
if (firstRender) {
setFirstRender(false);
if (!loaded) {
// If on first render we actually have a value, use it.

@@ -44,2 +43,3 @@ if (keyExists()) {

}
setLoaded(true);
}

@@ -61,3 +61,3 @@ // Restore value from window when requested

}
}, [defaultValue, firstRender, keyName, namespace, shouldRestore, reactState]);
}, [defaultValue, loaded, keyName, namespace, shouldRestore, reactState]);
var setValue = function (newVal) {

@@ -73,4 +73,4 @@ setReactState(newVal);

var value = reactState;
return [value, setValue, reset, restore];
return { value: value, setValue: setValue, loaded: loaded, reset: reset, restore: restore };
}
exports.useWindowGlobal = useWindowGlobal;
{
"name": "@devboldly/react-use-window-global",
"version": "0.0.1",
"version": "0.0.2",
"author": "Dev Boldly <devboldly@gmail.com>",

@@ -5,0 +5,0 @@ "description": "React hook for setting and getting globals via the Window Web API. Includes namespacing.",

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