New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@plq/use-persisted-state

Package Overview
Dependencies
Maintainers
1
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@plq/use-persisted-state - npm Package Compare versions

Comparing version 0.2.3 to 0.2.4

7

CHANGELOG.md

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

### [0.2.4](https://github.com/Akurganow/use-persisted-state/compare/v0.2.3...v0.2.4) (2020-06-02)
### Bug Fixes
* **storage listener:** listen key remove ([76d4bf5](https://github.com/Akurganow/use-persisted-state/commit/76d4bf5227920e0739fc8292ffc7e657bb03f7c5))
### [0.2.3](https://github.com/Akurganow/use-persisted-state/compare/v0.2.2...v0.2.3) (2020-06-02)

@@ -2,0 +9,0 @@

@@ -48,2 +48,14 @@ "use strict";

const handleStorage = (event) => {
if (event.key === safeStorageKey && event.newValue === null && event.oldValue !== null) {
let oldState = null;
try {
oldState = JSON.parse(event.oldValue);
}
catch (e) {
console.error('use-persisted-state: Can\'t parse old value from storage', e);
}
const oldValue = oldState && key in oldState ? oldState[key] : null;
if (oldValue !== initialValue)
setState(initialValue);
}
if (event.key === safeStorageKey && event.newValue !== null) {

@@ -50,0 +62,0 @@ let newState = null;

2

package.json
{
"name": "@plq/use-persisted-state",
"version": "0.2.3",
"version": "0.2.4",
"description": "useState hook with persistance in storage",

@@ -5,0 +5,0 @@ "main": "lib/index.js",

@@ -62,2 +62,16 @@ import React, { useState, useEffect } from 'react'

const handleStorage = (event: StorageEvent): void => {
if (event.key === safeStorageKey && event.newValue === null && event.oldValue !== null) {
let oldState = null
try {
oldState = JSON.parse(event.oldValue)
} catch (e) {
console.error('use-persisted-state: Can\'t parse old value from storage', e)
}
const oldValue = oldState && key in oldState ? oldState[key] as T : null
if (oldValue !== initialValue) setState(initialValue)
}
if (event.key === safeStorageKey && event.newValue !== null) {

@@ -64,0 +78,0 @@ let newState = null

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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