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

use-sync-external-store

Package Overview
Dependencies
Maintainers
3
Versions
1535
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

use-sync-external-store - npm Package Compare versions

Comparing version 0.0.0-experimental-71d16750c-20211202 to 0.0.0-experimental-720de7f81a-20241220

20

cjs/use-sync-external-store-shim.development.js

@@ -1,5 +0,6 @@

/** @license React vundefined
/**
* @license React
* use-sync-external-store-shim.development.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
* Copyright (c) Meta Platforms, Inc. and affiliates.
*

@@ -75,3 +76,4 @@ * This source code is licensed under the MIT license found in the

var objectIs = typeof Object.is === 'function' ? Object.is : is;
var objectIs = // $FlowFixMe[method-unbinding]
typeof Object.is === 'function' ? Object.is : is;

@@ -96,3 +98,3 @@ // dispatch for CommonJS interop named imports.

function useSyncExternalStore(subscribe, getSnapshot, // Note: The shim does not use getServerSnapshot, because pre-18 versions of
function useSyncExternalStore$2(subscribe, getSnapshot, // Note: The shim does not use getServerSnapshot, because pre-18 versions of
// React do not expose a way to check if we're hydrating. So users of the shim

@@ -120,3 +122,5 @@ // will need to track that themselves and return the correct value

if (!didWarnUncachedGetSnapshot) {
if (value !== getSnapshot()) {
var cachedValue = getSnapshot();
if (!objectIs(value, cachedValue)) {
error('The result of getSnapshot should be cached to avoid an infinite loop');

@@ -225,6 +229,6 @@

var shim = isServerEnvironment ? useSyncExternalStore$1 : useSyncExternalStore;
var useSyncExternalStore$2 = React.useSyncExternalStore !== undefined ? React.useSyncExternalStore : shim;
var shim = isServerEnvironment ? useSyncExternalStore$1 : useSyncExternalStore$2;
var useSyncExternalStore = React.useSyncExternalStore !== undefined ? React.useSyncExternalStore : shim;
exports.useSyncExternalStore = useSyncExternalStore$2;
exports.useSyncExternalStore = useSyncExternalStore;
/* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */

@@ -231,0 +235,0 @@ if (

@@ -1,5 +0,6 @@

/** @license React vundefined
/**
* @license React
* use-sync-external-store-shim.native.development.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
* Copyright (c) Meta Platforms, Inc. and affiliates.
*

@@ -75,3 +76,4 @@ * This source code is licensed under the MIT license found in the

var objectIs = typeof Object.is === 'function' ? Object.is : is;
var objectIs = // $FlowFixMe[method-unbinding]
typeof Object.is === 'function' ? Object.is : is;

@@ -96,3 +98,3 @@ // dispatch for CommonJS interop named imports.

function useSyncExternalStore(subscribe, getSnapshot, // Note: The shim does not use getServerSnapshot, because pre-18 versions of
function useSyncExternalStore$1(subscribe, getSnapshot, // Note: The shim does not use getServerSnapshot, because pre-18 versions of
// React do not expose a way to check if we're hydrating. So users of the shim

@@ -120,3 +122,5 @@ // will need to track that themselves and return the correct value

if (!didWarnUncachedGetSnapshot) {
if (value !== getSnapshot()) {
var cachedValue = getSnapshot();
if (!objectIs(value, cachedValue)) {
error('The result of getSnapshot should be cached to avoid an infinite loop');

@@ -213,6 +217,6 @@

var shim = useSyncExternalStore;
var useSyncExternalStore$1 = React.useSyncExternalStore !== undefined ? React.useSyncExternalStore : shim;
var shim = useSyncExternalStore$1;
var useSyncExternalStore = React.useSyncExternalStore !== undefined ? React.useSyncExternalStore : shim;
exports.useSyncExternalStore = useSyncExternalStore$1;
exports.useSyncExternalStore = useSyncExternalStore;
/* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */

@@ -219,0 +223,0 @@ if (

@@ -1,5 +0,6 @@

/** @license React vundefined
/**
* @license React
* use-sync-external-store-shim.native.production.min.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
* Copyright (c) Meta Platforms, Inc. and affiliates.
*

@@ -6,0 +7,0 @@ * This source code is licensed under the MIT license found in the

@@ -1,5 +0,6 @@

/** @license React vundefined
/**
* @license React
* use-sync-external-store-shim.production.min.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
* Copyright (c) Meta Platforms, Inc. and affiliates.
*

@@ -6,0 +7,0 @@ * This source code is licensed under the MIT license found in the

12

cjs/use-sync-external-store-shim/with-selector.development.js

@@ -1,5 +0,6 @@

/** @license React vundefined
/**
* @license React
* use-sync-external-store-shim/with-selector.development.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
* Copyright (c) Meta Platforms, Inc. and affiliates.
*

@@ -37,3 +38,4 @@ * This source code is licensed under the MIT license found in the

var objectIs = typeof Object.is === 'function' ? Object.is : is;
var objectIs = // $FlowFixMe[method-unbinding]
typeof Object.is === 'function' ? Object.is : is;

@@ -147,3 +149,5 @@ var useSyncExternalStore = shim.useSyncExternalStore;

useEffect(function () {
inst.hasValue = true;
// $FlowFixMe[incompatible-type] changing the variant using mutation isn't supported
inst.hasValue = true; // $FlowFixMe[incompatible-type]
inst.value = value;

@@ -150,0 +154,0 @@ }, [value]);

@@ -1,5 +0,6 @@

/** @license React vundefined
/**
* @license React
* use-sync-external-store-shim/with-selector.production.min.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
* Copyright (c) Meta Platforms, Inc. and affiliates.
*

@@ -9,4 +10,4 @@ * This source code is licensed under the MIT license found in the

*/
'use strict';var h=require("react"),n=require("use-sync-external-store/shim");function p(a,b){return a===b&&(0!==a||1/a===1/b)||a!==a&&b!==b}var q="function"===typeof Object.is?Object.is:p,r=n.useSyncExternalStore,t=h.useRef,u=h.useEffect,v=h.useMemo,w=h.useDebugValue;
exports.useSyncExternalStoreWithSelector=function(a,b,e,l,g){var c=t(null);if(null===c.current){var f={hasValue:!1,value:null};c.current=f}else f=c.current;c=v(function(){function a(a){if(!c){c=!0;d=a;a=l(a);if(void 0!==g&&f.hasValue){var b=f.value;if(g(b,a))return k=b}return k=a}b=k;if(q(d,a))return b;var e=l(a);if(void 0!==g&&g(b,e))return b;d=a;return k=e}var c=!1,d,k,m=void 0===e?null:e;return[function(){return a(b())},null===m?void 0:function(){return a(m())}]},[b,e,l,g]);var d=r(a,c[0],c[1]);
u(function(){f.hasValue=!0;f.value=d},[d]);w(d);return d};
'use strict';var h=require("react"),v=require("use-sync-external-store/shim");function w(b,c){return b===c&&(0!==b||1/b===1/c)||b!==b&&c!==c}var x="function"===typeof Object.is?Object.is:w,y=v.useSyncExternalStore,z=h.useRef,A=h.useEffect,B=h.useMemo,C=h.useDebugValue;
exports.useSyncExternalStoreWithSelector=function(b,c,m,n,g){var d=z(null);if(null===d.current){var e={hasValue:!1,value:null};d.current=e}else e=d.current;d=B(function(){function q(a){if(!r){r=!0;p=a;a=n(a);if(void 0!==g&&e.hasValue){var f=e.value;if(g(f,a))return k=f}return k=a}f=k;if(x(p,a))return f;var t=n(a);if(void 0!==g&&g(f,t))return f;p=a;return k=t}var r=!1,p,k,u=void 0===m?null:m;return[function(){return q(c())},null===u?void 0:function(){return q(u())}]},[c,m,n,g]);var l=y(b,d[0],d[1]);
A(function(){e.hasValue=!0;e.value=l},[l]);C(l);return l};

@@ -1,5 +0,6 @@

/** @license React vundefined
/**
* @license React
* use-sync-external-store-with-selector.development.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
* Copyright (c) Meta Platforms, Inc. and affiliates.
*

@@ -36,3 +37,4 @@ * This source code is licensed under the MIT license found in the

var objectIs = typeof Object.is === 'function' ? Object.is : is;
var objectIs = // $FlowFixMe[method-unbinding]
typeof Object.is === 'function' ? Object.is : is;

@@ -146,3 +148,5 @@ var useSyncExternalStore = React.useSyncExternalStore;

useEffect(function () {
inst.hasValue = true;
// $FlowFixMe[incompatible-type] changing the variant using mutation isn't supported
inst.hasValue = true; // $FlowFixMe[incompatible-type]
inst.value = value;

@@ -149,0 +153,0 @@ }, [value]);

@@ -1,5 +0,6 @@

/** @license React vundefined
/**
* @license React
* use-sync-external-store-with-selector.production.min.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
* Copyright (c) Meta Platforms, Inc. and affiliates.
*

@@ -9,4 +10,4 @@ * This source code is licensed under the MIT license found in the

*/
'use strict';var g=require("react");function n(a,b){return a===b&&(0!==a||1/a===1/b)||a!==a&&b!==b}var p="function"===typeof Object.is?Object.is:n,q=g.useSyncExternalStore,r=g.useRef,t=g.useEffect,u=g.useMemo,v=g.useDebugValue;
exports.useSyncExternalStoreWithSelector=function(a,b,e,l,h){var c=r(null);if(null===c.current){var f={hasValue:!1,value:null};c.current=f}else f=c.current;c=u(function(){function a(a){if(!c){c=!0;d=a;a=l(a);if(void 0!==h&&f.hasValue){var b=f.value;if(h(b,a))return k=b}return k=a}b=k;if(p(d,a))return b;var e=l(a);if(void 0!==h&&h(b,e))return b;d=a;return k=e}var c=!1,d,k,m=void 0===e?null:e;return[function(){return a(b())},null===m?void 0:function(){return a(m())}]},[b,e,l,h]);var d=q(a,c[0],c[1]);
t(function(){f.hasValue=!0;f.value=d},[d]);v(d);return d};
'use strict';var g=require("react");function v(b,c){return b===c&&(0!==b||1/b===1/c)||b!==b&&c!==c}var w="function"===typeof Object.is?Object.is:v,x=g.useSyncExternalStore,y=g.useRef,z=g.useEffect,A=g.useMemo,B=g.useDebugValue;
exports.useSyncExternalStoreWithSelector=function(b,c,m,n,h){var d=y(null);if(null===d.current){var e={hasValue:!1,value:null};d.current=e}else e=d.current;d=A(function(){function q(a){if(!r){r=!0;p=a;a=n(a);if(void 0!==h&&e.hasValue){var f=e.value;if(h(f,a))return k=f}return k=a}f=k;if(w(p,a))return f;var t=n(a);if(void 0!==h&&h(f,t))return f;p=a;return k=t}var r=!1,p,k,u=void 0===m?null:m;return[function(){return q(c())},null===u?void 0:function(){return q(u())}]},[c,m,n,h]);var l=x(b,d[0],d[1]);
z(function(){e.hasValue=!0;e.value=l},[l]);B(l);return l};

@@ -1,5 +0,6 @@

/** @license React vundefined
/**
* @license React
* use-sync-external-store.development.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
* Copyright (c) Meta Platforms, Inc. and affiliates.
*

@@ -69,3 +70,3 @@ * This source code is licensed under the MIT license found in the

{
error("The main 'use-sync-external-store' entry point is not supported; all it " + "does is re-export useSyncExternalStore from the 'react' package, so " + 'it only works with React 18+.' + '\n\n' + 'If you wish to support React 16 and 17, import from ' + "'use-sync-external-store/shim' instead. It will fall back to a shimmed" + 'implementation when the native one is not available.' + '\n\n' + "If you only support React 18+, you can import directly from 'react'.");
error("The main 'use-sync-external-store' entry point is not supported; all it " + "does is re-export useSyncExternalStore from the 'react' package, so " + 'it only works with React 18+.' + '\n\n' + 'If you wish to support React 16 and 17, import from ' + "'use-sync-external-store/shim' instead. It will fall back to a shimmed " + 'implementation when the native one is not available.' + '\n\n' + "If you only support React 18+, you can import directly from 'react'.");
}

@@ -72,0 +73,0 @@

@@ -1,5 +0,6 @@

/** @license React vundefined
/**
* @license React
* use-sync-external-store.production.min.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
* Copyright (c) Meta Platforms, Inc. and affiliates.
*

@@ -6,0 +7,0 @@ * This source code is licensed under the MIT license found in the

{
"name": "use-sync-external-store",
"description": "Backwards compatible shim for React's useSyncExternalStore. Works with any React that supports hooks.",
"version": "0.0.0-experimental-71d16750c-20211202",
"version": "0.0.0-experimental-720de7f81a-20241220",
"repository": {

@@ -13,3 +13,2 @@ "type": "git",

"README.md",
"build-info.json",
"index.js",

@@ -24,4 +23,4 @@ "index.native.js",

"peerDependencies": {
"react": "0.0.0-experimental-71d16750c-20211202"
"react": "0.0.0-experimental-720de7f81a-20241220"
}
}
# use-sync-external-store
Backwards compatible shim for React's `useSyncExternalStore`. Works with any React that supports hooks.
Backwards-compatible shim for [`React.useSyncExternalStore`](https://reactjs.org/docs/hooks-reference.html#usesyncexternalstore). Works with any React that supports Hooks.
Until `useSyncExternalStore` is documented, refer to https://github.com/reactwg/react-18/discussions/86
See also https://github.com/reactwg/react-18/discussions/86.

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