easy-peasy

Easy peasy global state for React

Github星跟蹤圖

npm
MIT License
Travis
Codecov

npm install easy-peasy

Step 1 - Create your store

const store = createStore({
  todos: {
    items: ['Create store', 'Wrap application', 'Use store'],
    add: action((state, payload) => {
      state.items.push(payload)
    })
  }
});

Step 2 - Wrap your application

function App() {
  return (
    <StoreProvider store={store}>
      <TodoList />
    </StoreProvider>
  );
}

Step 3 - Use the store

function TodoList() {
  const todos = useStoreState(state => state.todos.items)
  const add = useStoreActions(actions => actions.todos.add)
  return (
    <div>
      {todos.map((todo, idx) => <div key={idx}>{todo}</div>)}
      <AddTodo onAdd={add} />
    </div>
  )
}

Features

  • Zero configuration
  • No boilerplate
  • React hooks based API
  • Computed properties - i.e. derived data
  • Data fetching / side effects
  • Persist state to session/local storage
  • Testing helpers
  • Extensive TypeScript support
  • Global, shared, or component level stores
  • React Native supported
  • Redux Dev Tools supported
  • Hot Reloading supported

Introduction

Easy Peasy provides you with an intuitive API to quickly and easily manage the state for your React application. Batteries are included - no configuration is required to support derived state, API calls, performance optimisation, developer tools etc.

Documentation

See the official website for tutorials, API docs, recipes, and more.

Backers ❤️

Extreme gratitude to all our backers! [Become a backer].

主要指標

概覽
名稱與所有者ctrlplusb/easy-peasy
主編程語言JavaScript
編程語言JavaScript (語言數: 4)
平台
許可證MIT License
所有者活动
創建於2018-10-21 20:52:18
推送於2025-08-21 16:09:42
最后一次提交2025-03-22 11:39:25
發布數113
最新版本名稱v6.1.0 (發布於 )
第一版名稱v0.1.0 (發布於 2018-10-22 13:59:45)
用户参与
星數5k
關注者數32
派生數193
提交數742
已啟用問題?
問題數553
打開的問題數10
拉請求數205
打開的拉請求數3
關閉的拉請求數185
项目设置
已啟用Wiki?
已存檔?
是復刻?
已鎖定?
是鏡像?
是私有?