1.0.2 • Published 5 months ago

preact-zustand v1.0.2

Weekly downloads
-
License
MIT
Repository
github
Last release
5 months ago

preact-zustand

🐻 State-management for Preact based Zustand.

Installation

npm install preact-zustand
# or
yarn add preact-zustand
# or
pnpm add preact-zustand

Usage

import { create } from 'preact-zustand'

interface BearState {
  bears: number
  increase: () => void
}

const useBearStore = create<BearState>((set) => ({
  bears: 0,
  increase: () => set((state) => ({ bears: state.bears + 1 })),
}))

function BearCounter() {
  const bears = useBearStore((state) => state.bears)
  return <h1>{bears} around here...</h1>
}

function Controls() {
  const increase = useBearStore((state) => state.increase)
  return <button onClick={increase}>one up</button>
}

License

MIT

1.0.2

5 months ago

1.0.1

6 months ago

1.0.0

6 months ago