1.0.2 • Published 2 years ago

use-easy-store v1.0.2

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

use-easy-store

一个有手就行的 react-hooks 状态管理库

下载

yarn add use-easy-store -S

使用

app.js

import { createEasyStore } from 'use-easy-store';

createEasyStore({
  numA: 0,
  numB: 0,
});

const App = (props) => {
  return props.children;
};

export default App;

A 组件内

import { useEasyStore, store } from 'use-easy-store';

const A = (props) => {
  const numA = useEasyStore((data) => data.numA);
  handleClick = () => {
    store.setImmerEasyState((data) => {
      data.numA = numA + 1;
    });
  };
  return (
    <div>
      {numA}
      <button onClick={handleClick}>更新numA</button>
    </div>
  );
};

export default A;
1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago