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

react-localstorage

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-localstorage - npm Package Compare versions

Comparing version 0.2.2 to 0.2.3

8

karma.conf.js

@@ -63,3 +63,11 @@ 'use strict';

// create a custom Chrome launcher without the support for localStorage
customLaunchers: {
Chrome_without_ls: {
base: 'Chrome',
flags: ['--disable-local-storage']
}
},
// Continuous Integration mode

@@ -66,0 +74,0 @@ // if true, Karma captures browsers, runs the tests and exits

2

package.json
{
"name": "react-localstorage",
"version": "0.2.2",
"version": "0.2.3",
"description": "A mixin for automatically synchronizing a component's state with localStorage.",

@@ -5,0 +5,0 @@ "main": "react-localstorage.js",

'use strict';
var React = require('react');
var invariant = require('react/lib/invariant');
var ls = global.localStorage;
var warn = require('react/lib/warning');
var hasLocalStorage = 'localStorage' in global;
var ls, testKey;
if (hasLocalStorage) {
testKey = 'react-localstorage.mixin.test-key';
try {
// Access to global `localStorage` property must be guarded as it
// fails under iOS private session mode.
ls = global.localStorage;
ls.setItem(testKey, 'foo');
ls.removeItem(testKey);
} catch (e) {
hasLocalStorage = false;
}
}
// Warn if localStorage cannot be found or accessed.
warn(
hasLocalStorage,
'localStorage not found. Component state will not be stored to localStorage.'
);
var Mixin = module.exports = {

@@ -18,3 +39,3 @@ /**

componentDidUpdate: function(prevProps, prevState) {
if (!ls || !this.__stateLoadedFromLS) return;
if (!hasLocalStorage || !this.__stateLoadedFromLS) return;
var key = getLocalStorageKey(this);

@@ -42,2 +63,3 @@ var prevStoredState = ls.getItem(key);

componentDidMount: function () {
if (!hasLocalStorage) return;
var me = this;

@@ -76,3 +98,3 @@ loadStateFromLocalStorage(this, function() {

function getDisplayName(component) {
// at least, we cannot get displayname
// at least, we cannot get displayname
// via this.displayname in react 0.12

@@ -79,0 +101,0 @@ return component.displayName || component.constructor.displayName;

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