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

use-location-state

Package Overview
Dependencies
Maintainers
1
Versions
31
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

use-location-state - npm Package Compare versions

Comparing version 2.4.0 to 2.5.0

17

dist/use-location-state.cjs.js

@@ -69,3 +69,5 @@ 'use strict';

window.addEventListener('hashchange', hashChangeHandler, false);
return function () { return window.removeEventListener('hashchange', hashChangeHandler, false); };
return function () {
return window.removeEventListener('hashchange', hashChangeHandler, false);
};
}, [enabled]);

@@ -124,2 +126,5 @@ return hashQSI;

: defaultValue;
if (action === null) {
return resetQueryStateItem(opts);
}
var newValue = reducer(currentValue !== null && currentValue !== void 0 ? currentValue : defaultValue, action);

@@ -137,3 +142,4 @@ var newQueryStateValue = queryStateCore.toQueryStateValue(newValue);

if (stripDefaults) {
if (Array.isArray(defaultValue) && sameAsJsonString(newValue, defaultValue)) {
if (Array.isArray(defaultValue) &&
sameAsJsonString(newValue, defaultValue)) {
return resetQueryStateItem(opts);

@@ -225,3 +231,4 @@ }

var defaultValue = react.useState(function () {
return maybeInitStateFnOrOpts && typeof maybeInitStateFnOrOpts === 'function'
return maybeInitStateFnOrOpts &&
typeof maybeInitStateFnOrOpts === 'function'
? maybeInitStateFnOrOpts(initialStateOrInitialArg)

@@ -265,3 +272,5 @@ : initialStateOrInitialArg;

var currentState = getLocationState();
var currentValue = itemName in currentState ? currentState[itemName] : defaultValue;
var currentValue = itemName in currentState
? currentState[itemName]
: defaultValue;
var newValue = reducer(currentValue, action);

@@ -268,0 +277,0 @@ if (newValue === defaultValue) {

@@ -65,3 +65,5 @@ import { useMemo, useState, useEffect, useRef, useLayoutEffect, useCallback } from 'react';

window.addEventListener('hashchange', hashChangeHandler, false);
return function () { return window.removeEventListener('hashchange', hashChangeHandler, false); };
return function () {
return window.removeEventListener('hashchange', hashChangeHandler, false);
};
}, [enabled]);

@@ -120,2 +122,5 @@ return hashQSI;

: defaultValue;
if (action === null) {
return resetQueryStateItem(opts);
}
var newValue = reducer(currentValue !== null && currentValue !== void 0 ? currentValue : defaultValue, action);

@@ -133,3 +138,4 @@ var newQueryStateValue = toQueryStateValue(newValue);

if (stripDefaults) {
if (Array.isArray(defaultValue) && sameAsJsonString(newValue, defaultValue)) {
if (Array.isArray(defaultValue) &&
sameAsJsonString(newValue, defaultValue)) {
return resetQueryStateItem(opts);

@@ -221,3 +227,4 @@ }

var defaultValue = useState(function () {
return maybeInitStateFnOrOpts && typeof maybeInitStateFnOrOpts === 'function'
return maybeInitStateFnOrOpts &&
typeof maybeInitStateFnOrOpts === 'function'
? maybeInitStateFnOrOpts(initialStateOrInitialArg)

@@ -261,3 +268,5 @@ : initialStateOrInitialArg;

var currentState = getLocationState();
var currentValue = itemName in currentState ? currentState[itemName] : defaultValue;
var currentValue = itemName in currentState
? currentState[itemName]
: defaultValue;
var newValue = reducer(currentValue, action);

@@ -264,0 +273,0 @@ if (newValue === defaultValue) {

@@ -5,3 +5,3 @@ import { LocationStateInterface } from './useLocationState.types';

}
export default function useLocationStateInterface({ disabled }?: Props): LocationStateInterface;
export default function useLocationStateInterface({ disabled, }?: Props): LocationStateInterface;
export {};
import { QueryStateOpts, SetQueryStringOptions } from './useQueryState.types';
import { ReducerState } from 'react';
import { Reducer, ReducerAction } from '../types/sharedTypes';
export declare type QueryDispatch<A> = (value: A, opts?: SetQueryStringOptions) => void;
export declare type QueryDispatch<A> = (value: A | null, opts?: SetQueryStringOptions) => void;
export declare function useQueryReducer<R extends Reducer<ReducerState<R>, ReducerAction<R>>>(itemName: string, reducer: R, initialState: ReducerState<R>, queryStateOpts?: QueryStateOpts): [ReducerState<R>, QueryDispatch<ReducerAction<R>>];
export declare function useQueryReducer<R extends Reducer<ReducerState<R>, ReducerAction<R>>, InitialArg>(itemName: string, reducer: R, initialArg: InitialArg, initStateFn: (initialArg: InitialArg) => ReducerState<R>, queryStateOpts?: QueryStateOpts): [ReducerState<R>, QueryDispatch<ReducerAction<R>>];

@@ -11,5 +11,5 @@ {

"dependencies": {
"query-state-core": "^2.4.0"
"query-state-core": "^2.5.0"
},
"version": "2.4.0",
"version": "2.5.0",
"author": "Felix Leupold <felix@xiel.de>",

@@ -42,3 +42,3 @@ "homepage": "https://github.com/xiel/use-location-state",

},
"gitHead": "378cd4bffb30a0f96f0d68b1959fb5050114a5cc"
"gitHead": "cbc9554bb95e8e40105d8b1d244e3ec4b78832e5"
}
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