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

@proscom/prostore-react

Package Overview
Dependencies
Maintainers
1
Versions
41
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@proscom/prostore-react - npm Package Compare versions

Comparing version 0.0.6 to 0.0.7

24

lib/useRequestStore.js

@@ -17,8 +17,26 @@ "use strict";

const ssrContext = react_1.useContext(ProstoreSsrContext_1.ProstoreSsrContext);
// Фейковое состояние для ререндера
const [, rerender] = react_1.useState(0);
// Локальная копия состояния стора
const [state, setState] = react_1.useState(() => {
const stateRef = react_1.useRef(null);
// Ссылка на текущий стор
const storeRef = react_1.useRef(null);
// Если стор изменился
if (store !== storeRef.current) {
// Запоминаем текущий стор
storeRef.current = store;
// Если в контексте есть значение, используем его
return store.getValueFromContext(ssrContext);
});
stateRef.current = store.getValueFromContext(ssrContext);
}
// Колбек для обновления состояния
const setState = react_1.useCallback((newState) => {
if (stateRef.current !== newState) {
stateRef.current = newState;
rerender(s => s + 1);
}
}, []);
// Подписываемся на изменения стора
useConnectStore_1.useConnectStore(store, setState);
// Локальная копия состояния стора
const state = stateRef.current;
// Проверка, нужно ли запрашивать данные

@@ -25,0 +43,0 @@ const queryCheck = storeUtils_1.checkRequestState(state, variables);

6

package.json
{
"name": "@proscom/prostore-react",
"version": "0.0.6",
"version": "0.0.7",
"description": "> TODO: description",

@@ -28,3 +28,3 @@ "author": "Andrew Starostin <a.starostin@proscom.ru>",

"dependencies": {
"@proscom/prostore": "^0.0.6"
"@proscom/prostore": "^0.0.7"
},

@@ -38,3 +38,3 @@ "devDependencies": {

},
"gitHead": "05b84a2076076ef6bc3da5b4028cb96625a964a2"
"gitHead": "546a1187ad179cde3439815b0fb085342f3841a5"
}

@@ -1,2 +0,2 @@

import {useMemo, useCallback, useContext, useEffect, useState, DependencyList} from 'react';
import {useMemo, useCallback, useContext, useEffect, useState, DependencyList, useRef} from 'react';
import { ProstoreSsrContext } from './ProstoreSsrContext';

@@ -25,9 +25,33 @@ import {CheckRequestResult, checkRequestState} from '@proscom/prostore/lib/storeUtils';

// Фейковое состояние для ререндера
const [, rerender] = useState(0);
// Локальная копия состояния стора
const [state, setState] = useState(() => {
const stateRef = useRef(null);
// Ссылка на текущий стор
const storeRef = useRef(null);
// Если стор изменился
if (store !== storeRef.current) {
// Запоминаем текущий стор
storeRef.current = store;
// Если в контексте есть значение, используем его
return store.getValueFromContext(ssrContext);
});
stateRef.current = store.getValueFromContext(ssrContext);
}
// Колбек для обновления состояния
const setState = useCallback((newState) => {
if (stateRef.current !== newState) {
stateRef.current = newState;
rerender(s => s + 1);
}
}, []);
// Подписываемся на изменения стора
useConnectStore(store, setState);
// Локальная копия состояния стора
const state = stateRef.current;
// Проверка, нужно ли запрашивать данные

@@ -34,0 +58,0 @@ const queryCheck = checkRequestState(state, variables);

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