@zjxpcyc/react-tiny-store
Version:
简易版 React hook store
42 lines (25 loc) • 800 B
Markdown
极简 `react` `store` 管理工具 .
此版本(v4)属于 `break change` ,不兼容老版本 (v3) 。老版本 (v3) 的 使用的说明,[请点击查询](./README.v3.md)。
```bash
npm install @zjxpcyc/react-tiny-store -S
```
```javascript
// store.js
import { create } from '@zjxpcyc/react-tiny-store';
const useCount = create(1);
export default useCount;
// 至此 store 定义结束
// 可以在任意的组件内使用这个 useCount hook
// app.jsx
import useCount from './store';
const App = () => {
const [count, setCount] = useCount();
return (
<button onClick={() => setCount(x => x + 1)}>count is {count}</button>
);
}
```
更多方式,请查询[说明文档](https://yansen_zh.gitee.io/react-tiny-store-doc/)