Open ysmood opened 2 months ago
Here's the example code of zustand from link:
import { create } from 'zustand' import { immer } from 'zustand/middleware/immer' type State = { count: number } type Actions = { increment: (qty: number) => void decrement: (qty: number) => void } export const useCountStore = create<State & Actions>()( immer((set) => ({ count: 0, increment: (qty: number) => set((state) => { state.count += qty }), decrement: (qty: number) => set((state) => { state.count -= qty }), })), )
Same logic and type safety in stalo:
stalo
import { create } from "stalo/lib/immer" export const [useStore, setStore] = create({ count: 1, }) export const increment = (n: number) => setStore((s) => { s.count += n }) export const decrement = (n: number) => setStore((s) => { s.count -= n })
Zustand doesn't have native devtools support:
https://youtu.be/DpQg0EDeTEc
Here's the example code of zustand from link:
Same logic and type safety in
stalo
: