jarjan / preact

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

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Nano Stores Preact

Preact 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/preact'

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

About

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

License:MIT License


Languages

Language:TypeScript 83.7%Language:JavaScript 16.3%