mobx-react-use-autorun 3.0.28 → 3.0.30

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +13 -8
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -25,12 +25,13 @@ Publish to npm repository
25
25
  ## Notes - Define state and props with useMobxState
26
26
 
27
27
  import { useMobxState, observer } from 'mobx-react-use-autorun';
28
+ import { useRef } from 'react';
28
29
 
29
30
  export default observer((props: {name: string}) => {
30
31
 
31
- const state = useMobxState({ randomNumber: 1 }, {...props});
32
+ const state = useMobxState({ randomNumber: 1 }, { ...props, divRef: useRef<any>() });
32
33
 
33
- return <div onClick={() => state.randomNumber = Math.random()}>
34
+ return <div ref={state.divRef} onClick={() => state.randomNumber = Math.random()}>
34
35
  {state.randomNumber}
35
36
  </div>
36
37
  })
@@ -49,7 +50,7 @@ Form validation<br/>
49
50
  submit: false,
50
51
  errors: {
51
52
  get name() {
52
- return state.submit && !state.name && "请填写名称";
53
+ return state.submit && !state.name && "Please fill in the username";
53
54
  },
54
55
  get hasError() {
55
56
  return Object.keys(state.errors).filter(s => s !== "hasError").some(s => (state.errors as any)[s]);
@@ -60,21 +61,25 @@ Form validation<br/>
60
61
  const ok = async () => {
61
62
  state.submit = true;
62
63
  if (state.errors.hasError) {
63
- MessageService.error("错误");
64
+ MessageService.error("Error");
64
65
  } else {
65
- MessageService.success("提交成功");
66
+ MessageService.success("Submitted successfully");
66
67
  }
67
68
  }
68
69
 
69
70
  return (<div className='flex flex-col' style={{ padding: "2em" }}>
70
- <TextField value={state.name} label="用户名" onChange={(e) => state.name = e.target.value} error={!!state.errors.name} helperText={state.errors.name} />
71
- <Button variant="contained" style={{ marginTop: "2em" }} onClick={ok} >提交</Button>
71
+ <TextField value={state.name} label="Username" onChange={(e) => state.name = e.target.value} error={!!state.errors.name} helperText={state.errors.name} />
72
+ <Button variant="contained" style={{ marginTop: "2em" }} onClick={ok} >Submit</Button>
72
73
  </div>)
73
74
  })
74
75
 
75
76
  useMobxState provides two usages.<br/>
76
77
 
77
- useMobxState({},{}) is easy to use, you can define state and third-party hooks.<br/>
78
+ useMobxState({
79
+
80
+ },{})
81
+
82
+ is easy to use, you can define state and third-party hooks.<br/>
78
83
 
79
84
  useMobxState(()=>({
80
85
  get (){
package/package.json CHANGED
@@ -1 +1 @@
1
- {"name":"mobx-react-use-autorun","version":"3.0.28","description":"React Hook for mobx","scripts":{"test":"npx -y -p typescript -p ts-node ts-node --skipProject bin/mobx_react_test.ts","build":"npx -y -p typescript -p ts-node ts-node --skipProject bin/mobx_react_build.ts","make":"npx -y -p typescript -p ts-node ts-node --skipProject bin/mobx_react_make.ts"},"dependencies":{"mobx":">=6.5.0","mobx-react-lite":">=3.3.0","react-use":">=17.3.2","rxjs":">=6.0.0"},"peerDependencies":{"react":">=16.8.0"},"license":"MIT","keywords":["react","mobx","typescript"],"main":"./dist/index.js","types":"./dist/index.d.ts","eslintConfig":{"extends":["react-app","react-app/jest"]},"homepage":"https://github.com/zdu-strong/mobx-react-use-autorun#readme","repository":{"type":"git","url":"git+https://github.com/zdu-strong/mobx-react-use-autorun.git"},"files":["lib","dist"],"bugs":{"url":"https://github.com/zdu-strong/mobx-react-use-autorun/issues"},"publishConfig":{"registry":"https://registry.npmjs.org/"}}
1
+ {"name":"mobx-react-use-autorun","version":"3.0.30","description":"React Hook for mobx","scripts":{"test":"npx -y -p typescript -p ts-node ts-node --skipProject bin/mobx_react_test.ts","build":"npx -y -p typescript -p ts-node ts-node --skipProject bin/mobx_react_build.ts","make":"npx -y -p typescript -p ts-node ts-node --skipProject bin/mobx_react_make.ts"},"dependencies":{"mobx":">=6.5.0","mobx-react-lite":">=3.3.0","react-use":">=17.3.2","rxjs":">=6.0.0"},"peerDependencies":{"react":">=16.8.0"},"license":"MIT","keywords":["react","mobx","typescript"],"main":"./dist/index.js","types":"./dist/index.d.ts","eslintConfig":{"extends":["react-app","react-app/jest"]},"homepage":"https://github.com/zdu-strong/mobx-react-use-autorun#readme","repository":{"type":"git","url":"git+https://github.com/zdu-strong/mobx-react-use-autorun.git"},"files":["lib","dist"],"bugs":{"url":"https://github.com/zdu-strong/mobx-react-use-autorun/issues"},"publishConfig":{"registry":"https://registry.npmjs.org/"}}