Skip to content
项目

bluebill1049/little-state-machine

在 GitHub 查看

关于

📠 持久化状态管理的 React 自定义 Hook

网站与应用开发

这些数字如何统计

可以做什么

  • Tiny, with no runtime dependencies
  • State persistence with session storage by default
  • Selectors to limit re-renders

实测星标增长

24小时
0
7天
0
15天
0
1个月
0

各周期内的星标净变化,周期相互重叠,并非每日新增。缺失的测量保持空白。星标代表关注度,不代表软件质量。

README.md

原文

Simple global state for React.

npm downloads npm License

Get started | Documentation | Quickstart

Features

  • Tiny, with no runtime dependencies
  • State persistence with session storage by default
  • Selectors to limit re-renders

Install

npm install little-state-machine

Quickstart

import { createStore, useStateMachine } from 'little-state-machine';

createStore({ count: 0 });

function increment(state) {
  return { ...state, count: state.count + 1 };
}

function Counter() {
  const { actions, state } = useStateMachine({ actions: { increment } });

  return <button onClick={() => actions.increment()}>{state.count}</button>;
}

Read the documentation for options, selectors, and TypeScript setup.

探索相关项目

加载中…