All Projects β†’ wobsoriano β†’ solid-zustand

wobsoriano / solid-zustand

Licence: MIT license
🐻 State management in Solid using zustand.

Programming Languages

typescript
32286 projects

Projects that are alternatives of or similar to solid-zustand

zoov
Use 🐻 Zustand with Module-like api
Stars: ✭ 24 (-45.45%)
Mutual labels:  state-management, zustand
zustood
πŸ»β€β„οΈ A modular store factory using zustand
Stars: ✭ 46 (+4.55%)
Mutual labels:  state-management, zustand
archimedes-js
Archimedes's implementation for JavaScript and TypeScript
Stars: ✭ 34 (-22.73%)
Mutual labels:  solid
resynced
An experimental hook that lets you have multiple components using multiple synced states using no context provider
Stars: ✭ 19 (-56.82%)
Mutual labels:  state-management
react-nested-loader
The easiest way to manage loaders/errors inside a button. NOT an UI lib.
Stars: ✭ 62 (+40.91%)
Mutual labels:  state-management
bloc samples
A collection of apps built with the Bloc library.
Stars: ✭ 39 (-11.36%)
Mutual labels:  state-management
react-cool-form
😎 πŸ“‹ React hooks for forms state and validation, less code more performant.
Stars: ✭ 246 (+459.09%)
Mutual labels:  state-management
useSharedState
useSharedState is a simple hook that can be used to share state between multiple React components.
Stars: ✭ 0 (-100%)
Mutual labels:  state-management
react-declarative
A React form builder which interacts with a JSON endpoint to generate nested 12-column grids with input fields and automatic state management in a declarative style. Endpoint is typed by TypeScript guards (IntelliSense available). This tool is based on material-ui components, so your application will look beautiful on any device...
Stars: ✭ 17 (-61.36%)
Mutual labels:  state-management
flow-state
UI state management with RxJS.
Stars: ✭ 33 (-25%)
Mutual labels:  state-management
tacky
Enterprise-level front-end framework based on react
Stars: ✭ 37 (-15.91%)
Mutual labels:  state-management
awesome-solid-js
Curated resources on building sites with SolidJS, a brand new way(now 1.0) to build Javascript based interactive web applications. A very close looking cousin to React/JSX by syntax, and to Svelte by few important principles(compiler and fine-grained reactivity), it's a highly optimised way to deliver web applications with best-in-class performa…
Stars: ✭ 317 (+620.45%)
Mutual labels:  solid
use-state-machine
Use Finite State Machines with React Hooks
Stars: ✭ 28 (-36.36%)
Mutual labels:  state-management
east-store
east-store is a state manager with easiest api that based hooks and immer.
Stars: ✭ 18 (-59.09%)
Mutual labels:  state-management
stadux
No description or website provided.
Stars: ✭ 15 (-65.91%)
Mutual labels:  state-management
hooksy
Simple app state management based on react hooks
Stars: ✭ 58 (+31.82%)
Mutual labels:  state-management
agile
🌌 Global State and Logic Library for JavaScript/Typescript applications
Stars: ✭ 90 (+104.55%)
Mutual labels:  state-management
flutter examples
Random flutter examples
Stars: ✭ 18 (-59.09%)
Mutual labels:  state-management
redelay
Clojure library for first class lifecycle-managed state.
Stars: ✭ 44 (+0%)
Mutual labels:  state-management
react-evoke
Straightforward action-driven state management for straightforward apps built with Suspense
Stars: ✭ 15 (-65.91%)
Mutual labels:  state-management

solid-zustand

npm (tag) npm bundle size NPM

🐻 State management in Solid using zustand.

Install

pnpm add zustand solid-zustand

Demo: https://codesandbox.io/s/solid-zustand-demo-dmt4r

Example

import create from 'solid-zustand'

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

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

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

function Controls() {
  const state = useStore()
  return (
    <>
      <button onClick={state.increase}>one up</button>
      {/* Or */}
      <button onClick={() => useStore.setState((prev) => ({ bears: prev.bears + 1 }))}>
        one up
      </button>
    </>
  )
}

Selecting multiple state slices

Since solid-zustand uses createStore to store updates from zustand, state slices only works on plain objects and arrays (as of v1.4.0).

// Do this
const useStore = create(set => ({
  bears: {
    count: 0,
  }
}));
const bears = useStore(state => state.bears); // <div>{bears.count}</div>

// Don't
const useStore = create(set => ({
  bears: 0
}));
const count = useStore(state => state.bears); // <div>{count}</div> Always 0

Multiple state-picks also works

import shallow from 'zustand/shallow';

// Object pick, either state.bears or state.bulls change
const { bears, bulls } = useStore(
  state => ({ bears: state.bears, bulls: state.bulls }),
  shallow,
);

// Array pick, either state.bears or state.bulls change
const [bears, bulls] = useStore(state => [state.bears, state.bulls], shallow);

License

MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].