@nanostores/react
Advanced tools
Comparing version 0.1.5 to 0.2.0
15
index.js
import { listenKeys } from 'nanostores' | ||
import React from 'react' | ||
import { batch } from './batch/index.js' | ||
export { batch } | ||
export function useStore(store, opts = {}) { | ||
@@ -21,11 +17,10 @@ let [, forceRender] = React.useState({}) | ||
React.useEffect(() => { | ||
let rerender = () => { | ||
batch(() => { | ||
if (opts.keys) { | ||
return listenKeys(store, opts.keys, () => { | ||
forceRender({}) | ||
}) | ||
} | ||
if (opts.keys) { | ||
return listenKeys(store, opts.keys, rerender) | ||
} else { | ||
return store.listen(rerender) | ||
return store.listen(() => { | ||
forceRender({}) | ||
}) | ||
} | ||
@@ -32,0 +27,0 @@ }, [store, '' + opts.keys]) |
{ | ||
"name": "@nanostores/react", | ||
"version": "0.1.5", | ||
"version": "0.2.0", | ||
"description": "React integration for Nano Stores, a tiny state manager with many atomic tree-shakable stores", | ||
@@ -22,5 +22,2 @@ "keywords": [ | ||
}, | ||
"react-native": { | ||
"./batch/index.js": "./batch/index.native.js" | ||
}, | ||
"engines": { | ||
@@ -31,5 +28,5 @@ "node": "^12.0.0 || ^14.0.0 || >=16.0.0" | ||
"nanostores": "^0.5.2", | ||
"react": ">=16.8.0", | ||
"react-dom": ">=16.8.0" | ||
"react": ">=18.0.0", | ||
"react-dom": ">=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
5739
5
109