Comparing version 5.0.0-alpha.0 to 5.0.0-alpha.1
22
index.js
@@ -5,9 +5,23 @@ 'use strict'; | ||
var ReactExports = require('react'); | ||
var useSyncExternalStoreExports = require('use-sync-external-store/shim/with-selector'); | ||
var useDebugValue = ReactExports.useDebugValue; | ||
var useSyncExternalStoreWithSelector = useSyncExternalStoreExports.useSyncExternalStoreWithSelector; | ||
var useDebugValue = ReactExports.useDebugValue, | ||
useMemo = ReactExports.useMemo, | ||
useSyncExternalStore = ReactExports.useSyncExternalStore; | ||
var identity = function identity(arg) { | ||
return arg; | ||
}; | ||
var useMemoSelector = function useMemoSelector(getState, selector) { | ||
return useMemo(function () { | ||
var lastSlice; | ||
var lastState; | ||
return function () { | ||
var state = getState(); | ||
if (!Object.is(lastState, state)) { | ||
lastSlice = selector(state); | ||
lastState = state; | ||
} | ||
return lastSlice; | ||
}; | ||
}, [getState, selector]); | ||
}; | ||
function useStore(api, selector) { | ||
@@ -17,3 +31,3 @@ if (selector === void 0) { | ||
} | ||
var slice = useSyncExternalStoreWithSelector(api.subscribe, api.getState, api.getInitialState, selector); | ||
var slice = useSyncExternalStore(api.subscribe, useMemoSelector(api.getState, selector), useMemoSelector(api.getInitialState, selector)); | ||
useDebugValue(slice); | ||
@@ -20,0 +34,0 @@ return slice; |
{ | ||
"name": "zustand", | ||
"private": false, | ||
"version": "5.0.0-alpha.0", | ||
"version": "5.0.0-alpha.1", | ||
"publishConfig": { | ||
@@ -6,0 +6,0 @@ "tag": "next" |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
99645
1793
0