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

@nanostores/react

Package Overview
Dependencies
Maintainers
3
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@nanostores/react - npm Package Compare versions

Comparing version 0.1.3 to 0.1.4

errors.ts

40

index.d.ts
import { MapStore, Store, StoreValue } from 'nanostores'
export interface UseStoreOptions<
SomeStore,
Key extends string | number | symbol
> {
type AllKeys<T> = T extends any ? keyof T : never
export interface UseStoreOptions<SomeStore, Key extends PropertyKey> {
keys?: SomeStore extends MapStore ? Key[] : never

@@ -22,3 +21,3 @@ }

* let page = useStore(router)
* if (page.router === 'home') {
* if (page.route === 'home') {
* return <HomePage />

@@ -34,5 +33,34 @@ * } else {

*/
export function useStore<SomeStore extends Store>(
store: SomeStore
): StoreValue<SomeStore>
/**
* Subscribe to store changes and get store’s value.
*
* Can be user with store builder too.
*
* ```js
* import { useStore } from 'nanostores/react'
*
* import { router } from '../store/router'
*
* export const Layout = () => {
* let page = useStore(router, { keys: [ 'route' ] })
* if (page.route === 'home') {
* return <HomePage />
* } else {
* return <Error404 />
* }
* }
* ```
*
* @param store Store instance.
* @param options Subscription configuration.
* `keys` attribute controls which store value properties will be returned and listened to.
* @returns Store value.
*/
export function useStore<
SomeStore extends Store,
Key extends keyof StoreValue<SomeStore>
Key extends AllKeys<StoreValue<SomeStore>>
>(

@@ -39,0 +67,0 @@ store: SomeStore,

2

package.json
{
"name": "@nanostores/react",
"version": "0.1.3",
"version": "0.1.4",
"description": "React integration for Nano Stores, a tiny state manager with many atomic tree-shakable stores",

@@ -5,0 +5,0 @@ "keywords": [

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