@sukka/nanostores-react
TypeScript icon, indicating that this package has built-in type declarations

0.1.2 • Public • Published

Nano Stores React

React integration for Nano Stores, a tiny state manager with many atomic tree-shakable stores.

  • Small. Less than 1 KB. Zero dependencies.
  • Fast. With small atomic and derived stores, you do not need to call the selector function for all components on every store change.
  • Tree Shakable. The chunk contains only stores used by components in the chunk.
  • Was designed to move logic from components to stores.
  • It has good TypeScript support.
import { useStore } from '@nanostores/react'

import { profile } from '../stores/profile.js'
import { User } from '../stores/user.js'

export const Header = () => {
  const { userId } = useStore(profile)
  const currentUser = useStore(User(userId))
  return <header>{currentUser.name}</header>
}
Sponsored by Evil Martians

Package Sidebar

Install

npm i @sukka/nanostores-react

Weekly Downloads

1

Version

0.1.2

License

MIT

Unpacked Size

9.65 kB

Total Files

8

Last publish

Collaborators

  • sukkaw