mobx-react-use-autorun 3.0.30 → 3.0.32
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.
- package/README.md +29 -6
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -29,9 +29,17 @@ Publish to npm repository
|
|
|
29
29
|
|
|
30
30
|
export default observer((props: {name: string}) => {
|
|
31
31
|
|
|
32
|
-
const state = useMobxState({
|
|
32
|
+
const state = useMobxState({
|
|
33
|
+
randomNumber: 1
|
|
34
|
+
}, {
|
|
35
|
+
...props,
|
|
36
|
+
divRef: useRef<any>()
|
|
37
|
+
});
|
|
33
38
|
|
|
34
|
-
return <div
|
|
39
|
+
return <div
|
|
40
|
+
ref={state.divRef}
|
|
41
|
+
onClick={() => state.randomNumber = Math.random()}
|
|
42
|
+
>
|
|
35
43
|
{state.randomNumber}
|
|
36
44
|
</div>
|
|
37
45
|
})
|
|
@@ -50,10 +58,14 @@ Form validation<br/>
|
|
|
50
58
|
submit: false,
|
|
51
59
|
errors: {
|
|
52
60
|
get name() {
|
|
53
|
-
return state.submit &&
|
|
61
|
+
return state.submit &&
|
|
62
|
+
!state.name &&
|
|
63
|
+
"Please fill in the username";
|
|
54
64
|
},
|
|
55
65
|
get hasError() {
|
|
56
|
-
return Object.keys(state.errors)
|
|
66
|
+
return Object.keys(state.errors)
|
|
67
|
+
.filter(s => s !== "hasError")
|
|
68
|
+
.some(s => (state.errors as any)[s]);
|
|
57
69
|
}
|
|
58
70
|
}
|
|
59
71
|
}));
|
|
@@ -68,8 +80,18 @@ Form validation<br/>
|
|
|
68
80
|
}
|
|
69
81
|
|
|
70
82
|
return (<div className='flex flex-col' style={{ padding: "2em" }}>
|
|
71
|
-
<TextField
|
|
72
|
-
|
|
83
|
+
<TextField
|
|
84
|
+
value={state.name}
|
|
85
|
+
label="Username"
|
|
86
|
+
onChange={(e) => state.name = e.target.value}
|
|
87
|
+
error={!!state.errors.name}
|
|
88
|
+
helperText={state.errors.name}
|
|
89
|
+
/>
|
|
90
|
+
<Button
|
|
91
|
+
variant="contained"
|
|
92
|
+
style={{ marginTop: "2em" }}
|
|
93
|
+
onClick={ok}
|
|
94
|
+
>Submit</Button>
|
|
73
95
|
</div>)
|
|
74
96
|
})
|
|
75
97
|
|
|
@@ -158,6 +180,7 @@ useUnmount is executed when the component is unmount.<br/>
|
|
|
158
180
|
|
|
159
181
|
import { useMount, useUnmount } from 'react-use'
|
|
160
182
|
import { Subscription, of, tap } from 'rxjs'
|
|
183
|
+
import { useMobxState } from 'mobx-react-use-autorun'
|
|
161
184
|
|
|
162
185
|
const state = useMobxState({
|
|
163
186
|
subscription: new Subscription()
|
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"mobx-react-use-autorun","version":"3.0.
|
|
1
|
+
{"name":"mobx-react-use-autorun","version":"3.0.32","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/"}}
|