0.1.4 • Published 7 months ago

@e7w/easy-model v0.1.4

Weekly downloads
-
License
MIT
Repository
-
Last release
7 months ago

easy-model

一个简单的react状态管理库

示例

import { useModel } from "@e7w/easy-model";

class MTest {
  constructor(public name: string) {}

  value = 0;

  random() {
    this.value = Math.random();
  }
}

function TestComA() {
  const { value, random } = useModel(MTest, ["test"]);
  return (
    <div>
      <span>{value}</span>
      <button onClick={random}>changeValue</button>
    </div>
  );
}

function TestComB() {
  const { value } = useModel(MTest, ["test"]);
  return <span>{value}</span>;
}

render(
  <div>
    <TestComA />
    <TestComB />
  </div>
);
// 当点击ComA的div时,两个组件都会更新
0.1.0

8 months ago

0.1.2

8 months ago

0.1.1

8 months ago

0.1.4

7 months ago

0.1.3

7 months ago

0.0.10

2 years ago

0.0.11

2 years ago

0.0.12

2 years ago

0.0.3

2 years ago

0.0.2

2 years ago

0.0.9

2 years ago

0.0.8

2 years ago

0.0.5

2 years ago

0.0.4

2 years ago

0.0.7

2 years ago

0.0.6

2 years ago

0.0.1

3 years ago