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

hookstore

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

hookstore - npm Package Compare versions

Comparing version 0.1.4 to 0.1.5

LICENSE

27

es/provider.js
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
import React, { createElement, createContext, useContext, useEffect, useMemo, useRef, useState, useDebugValue } from 'react';
import { diff } from 'deep-diff';
import invariant from 'invariant';

@@ -48,6 +47,3 @@ import clonedeep from 'lodash.clonedeep';

state = _useState2[0],
dispatch = _useState2[1]; // for data diff
var stateRef = useRef(null); // const listenRef = useRef([]);
dispatch = _useState2[1]; // const listenRef = useRef([]);
// const subscribe = useCallback(listener => {

@@ -60,2 +56,3 @@ // listenRef.current.push(listener);

var providerValue = {

@@ -75,13 +72,17 @@ state: state,

ContextMap.set(namespace, Context);
} // update state in Context
} // update state in Context after every re-render
Context._currentValue.state = state;
useMemo(function () {
if (!getState(namespace)) {
stateRef.current = clonedeep(initialState);
StateRefMap.set(namespace, stateRef);
}
}, [namespace, initialState]);
useEffect(function () {
Context._currentValue.state = state;
}); // for data diff
var stateRef = useRef(null);
if (!getState(namespace)) {
stateRef.current = clonedeep(initialState);
StateRefMap.set(namespace, stateRef);
}
useEffect(function () {
// clean

@@ -88,0 +89,0 @@ return function () {

@@ -17,4 +17,2 @@ "use strict";

var _deepDiff = require("deep-diff");
var _invariant = _interopRequireDefault(require("invariant"));

@@ -72,6 +70,3 @@

state = _useState2[0],
dispatch = _useState2[1]; // for data diff
var stateRef = (0, _react.useRef)(null); // const listenRef = useRef([]);
dispatch = _useState2[1]; // const listenRef = useRef([]);
// const subscribe = useCallback(listener => {

@@ -84,2 +79,3 @@ // listenRef.current.push(listener);

var providerValue = {

@@ -101,13 +97,17 @@ state: state,

_context.ContextMap.set(namespace, Context);
} // update state in Context
} // update state in Context after every re-render
Context._currentValue.state = state;
(0, _react.useMemo)(function () {
if (!(0, _stateRef.getState)(namespace)) {
stateRef.current = (0, _lodash.default)(initialState);
(0, _react.useEffect)(function () {
Context._currentValue.state = state;
}); // for data diff
_stateRef.StateRefMap.set(namespace, stateRef);
}
}, [namespace, initialState]);
var stateRef = (0, _react.useRef)(null);
if (!(0, _stateRef.getState)(namespace)) {
stateRef.current = (0, _lodash.default)(initialState);
_stateRef.StateRefMap.set(namespace, stateRef);
}
(0, _react.useEffect)(function () {

@@ -114,0 +114,0 @@ // clean

{
"name": "hookstore",
"version": "0.1.4",
"version": "0.1.5",
"description": "React useContext Hook based and lightweight state manage library.",

@@ -11,7 +11,7 @@ "main": "lib/index.js",

"type": "git",
"url": "https://github.com/chemdemo/hookstore"
"url": "https://github.com/react-kit/hookstore"
},
"homepage": "https://github.com/chemdemo/hookstore",
"homepage": "https://github.com/react-kit/hookstore",
"bugs": {
"url": "https://github.com/chemdemo/hookstore/issues"
"url": "https://github.com/react-kit/hookstore/issues"
},

@@ -44,3 +44,4 @@ "authors": [

"index.d.ts"
]
],
"gitHead": "1492e0febd45bd22ca99a7b6bfa597ff754946bc"
}

@@ -6,6 +6,5 @@ English|[简体中文](./README.zh-CN.md)

[![NPM version](https://img.shields.io/npm/v/hookstore.svg?style=flat)](https://npmjs.org/package/hookstore)
[![Build Status](https://img.shields.io/travis/chemdemo/hookstore.svg?style=flat)](https://travis-ci.org/chemdemo/hookstore)
[![Coverage Status](https://img.shields.io/coveralls/chemdemo/hookstore.svg?style=flat)](https://coveralls.io/r/chemdemo/hookstore)
[![Build Status](https://img.shields.io/travis/react-kit/hookstore.svg?style=flat)](https://travis-ci.org/react-kit/hookstore)
[![Coverage Status](https://img.shields.io/coveralls/react-kit/hookstore.svg?style=flat)](https://coveralls.io/r/react-kit/hookstore)
[![NPM downloads](http://img.shields.io/npm/dm/hookstore.svg?style=flat)](https://npmjs.org/package/hookstore)
[![Dependencies](https://david-dm.org/chemdemo/hookstore/status.svg)](https://david-dm.org/chemdemo/hookstore)

@@ -308,2 +307,2 @@ React Hooks (useContext) based and lightweight state manage library.

MIT © [chemdemo](https://github.com/chemdemo)
MIT

@@ -6,6 +6,5 @@ 简体中文|[English](./README.md)

[![NPM version](https://img.shields.io/npm/v/hookstore.svg?style=flat)](https://npmjs.org/package/hookstore)
[![Build Status](https://img.shields.io/travis/chemdemo/hookstore.svg?style=flat)](https://travis-ci.org/chemdemo/hookstore)
[![Coverage Status](https://img.shields.io/coveralls/chemdemo/hookstore.svg?style=flat)](https://coveralls.io/r/chemdemo/hookstore)
[![Build Status](https://img.shields.io/travis/react-kit/hookstore.svg?style=flat)](https://travis-ci.org/react-kit/hookstore)
[![Coverage Status](https://img.shields.io/coveralls/react-kit/hookstore.svg?style=flat)](https://coveralls.io/r/react-kit/hookstore)
[![NPM downloads](http://img.shields.io/npm/dm/hookstore.svg?style=flat)](https://npmjs.org/package/hookstore)
[![Dependencies](https://david-dm.org/chemdemo/hookstore/status.svg)](https://david-dm.org/chemdemo/hookstore)

@@ -310,2 +309,2 @@ 基于React Hooks(useContext)的轻量级状态管理方案。

MIT © [chemdemo](https://github.com/chemdemo)
MIT

@@ -11,3 +11,2 @@ import React, {

} from 'react';
import { diff } from 'deep-diff';
import invariant from 'invariant';

@@ -47,4 +46,2 @@ import clonedeep from 'lodash.clonedeep';

const [state, dispatch] = useState(initialState);
// for data diff
const stateRef = useRef(null);
// const listenRef = useRef([]);

@@ -72,12 +69,15 @@ // const subscribe = useCallback(listener => {

}
// update state in Context
Context._currentValue.state = state;
useMemo(() => {
if (!getState(namespace)) {
stateRef.current = clonedeep(initialState);
StateRefMap.set(namespace, stateRef);
}
}, [namespace, initialState]);
// update state in Context after every re-render
useEffect(() => {
Context._currentValue.state = state;
});
// for data diff
const stateRef = useRef(null);
if (!getState(namespace)) {
stateRef.current = clonedeep(initialState);
StateRefMap.set(namespace, stateRef);
}
useEffect(() => {

@@ -84,0 +84,0 @@ // clean

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