@ice/store v1.3.0-beta-0
icestore
Lightweight state management solution based on React Hooks.
Introduction
icestore is a lightweight React state management library based on hooks. It has the following core features:
- Minimal & Familiar API: No additional learning costs, easy to get started with the knowledge of Redux && React Hooks.
- Built in Async Status: Records loading and error status of async actions, simplifying the rendering logic in the view layer.
- Class Component Support: Make old projects enjoying the fun of lightweight state management with friendly compatibility strategy.
- TypeScript Support: Provide complete type definitions to support intelliSense in VS Code.
See the comparison table for more details.
Basic example
import React from 'react';
import ReactDOM from 'react-dom';
import { createStore } from '@ice/store';
const delay = (time) => new Promise((resolve) => setTimeout(() => resolve(), time));
// 1️⃣ Use a model to define your store
const counter = {
state: 0,
reducers: {
increment:(prevState) => prevState + 1,
decrement:(prevState) => prevState - 1,
},
effects: () => ({
async decrementAsync(payload, rootState) {
await delay(1000);
this.decrement();
},
})
};
const models = {
counter,
};
// 2️⃣ Create the store
const store = createStore(models);
// 3️⃣ Consume model
const { useModel } = store;
function Counter() {
const [ count, dispatchers ] = useModel('counter');
const { increment, decrementAsync } = dispatchers;
return (
<div>
<span>{count}</span>
<button type="button" onClick={increment}>+</button>
<button type="button" onClick={decrementAsync}>-</button>
</div>
);
}
// 4️⃣ Wrap your components with Provider
const { Provider } = store;
function App() {
return (
<Provider>
<Counter />
</Provider>
);
}
const rootElement = document.getElementById('root');
ReactDOM.render(<App />, rootElement);Installation
icestore requires React 16.8.0 or later.
npm install @ice/store --saveAPI
Recipes
Upgrade Guidelines
Browser Compatibility
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
|---|---|---|---|---|---|---|
| ✔ | ✔ | ✔ | 9+ ✔ | ✔ | ✔ | ✔ |
Inspiration
icestore refines and builds upon the ideas of constate & rematch.
Contributors
Feel free to report any questions as an issue, we'd love to have your helping hand on icestore.
If you're interested in icestore, see CONTRIBUTING.md for more information to learn how to get started.
Community
| DingTalk community | GitHub issues | Gitter |
|---|---|---|
| issues | gitter |
License
3 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago






