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.3 to 0.0.4

16

dist/hooks/useWindowGlobal.js

@@ -21,5 +21,9 @@ "use strict";

var _d = React.useState(defaultValue), reactState = _d[0], setReactState = _d[1];
var emitterEventName = (namespace !== 'undefined' ? namespace + '.' : '') + keyName + ' change';
var setStateAndEmit = function (newState) {
setReactState(newState);
getEmitter().emit(emitterEventName);
};
React.useEffect(function () {
var aborted = false;
var emitterEventName = (namespace !== 'undefined' ? namespace + '.' : '') + keyName + ' change';
var setStateAndEmit = function (newState) {

@@ -31,3 +35,2 @@ setReactState(newState);

if (typeof window !== 'undefined') {
console.log(window);
var winObj_1 = getWinObj(namespace);

@@ -38,3 +41,3 @@ var emitter = getEmitter();

// Set up emitter
updateHandler = function (firedById) {
updateHandler = function () {
if (!aborted) {

@@ -81,6 +84,3 @@ setReactState(winObj_1[keyName]);

};
}, [defaultValue, loaded, keyName, namespace, shouldRestore, reactState, shouldPush]);
var setValue = function (newVal) {
setReactState(newVal);
};
}, [defaultValue, loaded, keyName, namespace, shouldRestore, reactState, shouldPush, emitterEventName]);
var restore = function () {

@@ -94,3 +94,3 @@ setShouldRestore(true);

var value = reactState;
return { value: value, setValue: setValue, loaded: loaded, reset: reset, restore: restore };
return { value: value, setValue: setStateAndEmit, loaded: loaded, reset: reset, restore: restore };
}

@@ -97,0 +97,0 @@ exports.useWindowGlobal = useWindowGlobal;

{
"name": "@devboldly/react-use-window-global",
"version": "0.0.3",
"version": "0.0.4",
"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