@nanostores/react
Advanced tools
Comparing version 0.6.0 to 0.7.0
@@ -1,5 +0,3 @@ | ||
import { Store, StoreValue } from 'nanostores' | ||
import type { Store, StoreValue } from 'nanostores' | ||
type AllKeys<T> = T extends any ? keyof T : never | ||
type StoreKeys<T> = T extends { setKey: (k: infer K, v: any) => unknown } | ||
@@ -43,21 +41,1 @@ ? K | ||
): StoreValue<SomeStore> | ||
/** | ||
* Batch React updates. It is just wrap for React’s `unstable_batchedUpdates` | ||
* with fix for React Native. | ||
* | ||
* ```js | ||
* import { batch } from 'nanostores/react' | ||
* | ||
* React.useEffect(() => { | ||
* let unbind = store.listen(() => { | ||
* batch(() => { | ||
* forceRender({}) | ||
* }) | ||
* }) | ||
* }) | ||
* ``` | ||
* | ||
* @param cb Callback to run in batching. | ||
*/ | ||
export function batch(cb: () => void): void |
@@ -5,3 +5,3 @@ import { listenKeys } from 'nanostores' | ||
export function useStore(store, opts = {}) { | ||
let sub = useCallback( | ||
let subscribe = useCallback( | ||
onChange => | ||
@@ -14,5 +14,5 @@ opts.keys | ||
let get = store.get.bind(store) | ||
let get = useCallback(() => store.value, [store]) | ||
return useSyncExternalStore(sub, get, get) | ||
return useSyncExternalStore(subscribe, get, get) | ||
} |
{ | ||
"name": "@nanostores/react", | ||
"version": "0.6.0", | ||
"version": "0.7.0", | ||
"description": "React integration for Nano Stores, a tiny state manager with many atomic tree-shakable stores", | ||
@@ -23,3 +23,3 @@ "keywords": [ | ||
"engines": { | ||
"node": "^16.0.0 || >=18.0.0" | ||
"node": "^16.0.0 || ^18.0.0 || >=20.0.0" | ||
}, | ||
@@ -33,5 +33,5 @@ "funding": [ | ||
"peerDependencies": { | ||
"nanostores": "^0.8.0", | ||
"nanostores": "^0.9.0", | ||
"react": ">=18.0.0" | ||
} | ||
} |
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
4300
50