mobx-react-use-autorun 3.0.14 → 3.0.20
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 +4 -5
- package/dist/lib/useMobxState.js +3 -2
- package/dist/lib/useMobxState.js.map +1 -1
- package/lib/lib/useMobxState.tsx +2 -2
- package/package.json +1 -60
package/README.md
CHANGED
|
@@ -14,22 +14,21 @@ In the project directory, you can run:<br/>
|
|
|
14
14
|
|
|
15
15
|
Run all unit tests.<br/>
|
|
16
16
|
|
|
17
|
-
|
|
18
17
|
### `npm run build`
|
|
19
18
|
|
|
20
19
|
Builds the files for production to the `dist` folder.<br/>
|
|
21
20
|
|
|
22
|
-
### `npm
|
|
21
|
+
### `npm run make`
|
|
23
22
|
|
|
24
23
|
Publish to npm repository
|
|
25
24
|
|
|
26
|
-
## Notes - Define state with useMobxState
|
|
25
|
+
## Notes - Define state and props with useMobxState
|
|
27
26
|
|
|
28
27
|
import { useMobxState, observer } from 'mobx-react-use-autorun';
|
|
29
28
|
|
|
30
|
-
export default observer(() => {
|
|
29
|
+
export default observer((props: {name: string}) => {
|
|
31
30
|
|
|
32
|
-
const state = useMobxState({ randomNumber: 1 });
|
|
31
|
+
const state = useMobxState({ randomNumber: 1 }, {...props});
|
|
33
32
|
|
|
34
33
|
return <div onClick={() => state.randomNumber = Math.random()}>
|
|
35
34
|
{state.randomNumber}
|
package/dist/lib/useMobxState.js
CHANGED
|
@@ -4,11 +4,12 @@ export function useMobxState(state, props) {
|
|
|
4
4
|
var mobxState = useLocalObservable(typeof state === "function" ? state : function () { return state; });
|
|
5
5
|
runInAction(function () {
|
|
6
6
|
var _a, _b;
|
|
7
|
+
var _c;
|
|
7
8
|
var propsResult = typeof props === "function" ? props() : props;
|
|
8
9
|
if (propsResult) {
|
|
9
10
|
for (var key in propsResult) {
|
|
10
|
-
if (isObservable(propsResult[key])) {
|
|
11
|
-
mobxState
|
|
11
|
+
if (isObservable(propsResult[key]) || ((_c = Object.getOwnPropertyDescriptor(propsResult, key)) === null || _c === void 0 ? void 0 : _c.get)) {
|
|
12
|
+
Object.defineProperty(mobxState, key, Object.getOwnPropertyDescriptor(propsResult, key));
|
|
12
13
|
}
|
|
13
14
|
else {
|
|
14
15
|
if (propsResult[key] !== mobxState[key]) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useMobxState.js","sourceRoot":"","sources":["../../lib/lib/useMobxState.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,MAAM,CAAC;AAC3E,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAErD,MAAM,UAAU,YAAY,CAAyD,KAAoB,EAAE,KAAqB;IAC5H,IAAM,SAAS,GAAG,kBAAkB,CAAC,OAAO,KAAK,KAAK,UAAU,CAAC,CAAC,CAAE,KAAa,CAAC,CAAC,CAAC,cAAM,OAAA,KAAK,EAAL,CAAK,CAAC,CAAC;IAEjG,WAAW,CAAC
|
|
1
|
+
{"version":3,"file":"useMobxState.js","sourceRoot":"","sources":["../../lib/lib/useMobxState.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,MAAM,CAAC;AAC3E,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAErD,MAAM,UAAU,YAAY,CAAyD,KAAoB,EAAE,KAAqB;IAC5H,IAAM,SAAS,GAAG,kBAAkB,CAAC,OAAO,KAAK,KAAK,UAAU,CAAC,CAAC,CAAE,KAAa,CAAC,CAAC,CAAC,cAAM,OAAA,KAAK,EAAL,CAAK,CAAC,CAAC;IAEjG,WAAW,CAAC;;;QACR,IAAM,WAAW,GAAG,OAAO,KAAK,KAAK,UAAU,CAAC,CAAC,CAAE,KAAa,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC;QAE3E,IAAI,WAAW,EAAE;YACb,KAAK,IAAM,GAAG,IAAI,WAAW,EAAE;gBAC3B,IAAI,YAAY,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,KAAI,MAAA,MAAM,CAAC,wBAAwB,CAAC,WAAW,EAAE,GAAG,CAAC,0CAAE,GAAG,CAAA,EAAE;oBAC1F,MAAM,CAAC,cAAc,CAAC,SAAS,EAAE,GAAG,EAAE,MAAM,CAAC,wBAAwB,CAAC,WAAW,EAAE,GAAG,CAAQ,CAAC,CAAA;iBAClG;qBAAM;oBACH,IAAI,WAAW,CAAC,GAAG,CAAC,KAAK,SAAS,CAAC,GAAG,CAAC,EAAE;wBACrC,MAAM,CAAC,SAAS,EAAE,GAAG,CAAC,CAAC;wBACvB,gBAAgB,CAAC,SAAS,YAAI,GAAC,GAAG,IAAG,WAAW,CAAC,GAAG,CAAC,iBAAM,GAAC,GAAG,IAAG,KAAK,MAAG,CAAA;qBAC7E;iBACJ;aACJ;SACJ;IACL,CAAC,CAAC,CAAA;IAEF,OAAO,SAAgB,CAAC;AAC5B,CAAC"}
|
package/lib/lib/useMobxState.tsx
CHANGED
|
@@ -9,8 +9,8 @@ export function useMobxState<T extends Record<any, any>, P extends Record<any, a
|
|
|
9
9
|
|
|
10
10
|
if (propsResult) {
|
|
11
11
|
for (const key in propsResult) {
|
|
12
|
-
if (isObservable(propsResult[key])) {
|
|
13
|
-
mobxState
|
|
12
|
+
if (isObservable(propsResult[key]) || Object.getOwnPropertyDescriptor(propsResult, key)?.get) {
|
|
13
|
+
Object.defineProperty(mobxState, key, Object.getOwnPropertyDescriptor(propsResult, key) as any)
|
|
14
14
|
} else {
|
|
15
15
|
if (propsResult[key] !== mobxState[key]) {
|
|
16
16
|
remove(mobxState, key);
|
package/package.json
CHANGED
|
@@ -1,60 +1 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "mobx-react-use-autorun",
|
|
3
|
-
"version": "3.0.14",
|
|
4
|
-
"description": "React Hook for mobx",
|
|
5
|
-
"scripts": {
|
|
6
|
-
"build": "npm install -g typescript@4.6.3 @types/node@17.0.23 ts-node@10.7.0 cross-env@7.0.3 && cross-env TS_NODE_SKIP_PROJECT=true ts-node bin/mobx_react_build.ts",
|
|
7
|
-
"test": "npm install -g typescript@4.6.3 @types/node@17.0.23 ts-node@10.7.0 cross-env@7.0.3 && cross-env TS_NODE_SKIP_PROJECT=true ts-node bin/mobx_react_test.ts",
|
|
8
|
-
"prepublishOnly": "npm test && npm run build"
|
|
9
|
-
},
|
|
10
|
-
"dependencies": {
|
|
11
|
-
"mobx": ">=6.5.0",
|
|
12
|
-
"mobx-react-lite": ">=3.3.0",
|
|
13
|
-
"react-use": ">=17.3.2"
|
|
14
|
-
},
|
|
15
|
-
"peerDependencies": {
|
|
16
|
-
"react": ">=16.8.0"
|
|
17
|
-
},
|
|
18
|
-
"devDependencies": {
|
|
19
|
-
"@types/node": "17.0.31",
|
|
20
|
-
"@types/react": "17.0.44",
|
|
21
|
-
"typescript": "4.6.4",
|
|
22
|
-
"@testing-library/jest-dom": "5.16.4",
|
|
23
|
-
"@testing-library/react": "12.1.5",
|
|
24
|
-
"@testing-library/user-event": "13.5.0",
|
|
25
|
-
"@types/jest": "27.5.0",
|
|
26
|
-
"@types/react-dom": "18.0.3",
|
|
27
|
-
"react": "17.0.2",
|
|
28
|
-
"react-dom": "17.0.2",
|
|
29
|
-
"react-scripts": "5.0.1"
|
|
30
|
-
},
|
|
31
|
-
"license": "MIT",
|
|
32
|
-
"keywords": [
|
|
33
|
-
"react",
|
|
34
|
-
"mobx",
|
|
35
|
-
"typescript"
|
|
36
|
-
],
|
|
37
|
-
"main": "./dist/index.js",
|
|
38
|
-
"types": "./dist/index.d.ts",
|
|
39
|
-
"eslintConfig": {
|
|
40
|
-
"extends": [
|
|
41
|
-
"react-app",
|
|
42
|
-
"react-app/jest"
|
|
43
|
-
]
|
|
44
|
-
},
|
|
45
|
-
"homepage": "https://github.com/zdu-strong/mobx-react-use-autorun#readme",
|
|
46
|
-
"repository": {
|
|
47
|
-
"type": "git",
|
|
48
|
-
"url": "git+https://github.com/zdu-strong/mobx-react-use-autorun.git"
|
|
49
|
-
},
|
|
50
|
-
"files": [
|
|
51
|
-
"lib",
|
|
52
|
-
"dist"
|
|
53
|
-
],
|
|
54
|
-
"bugs": {
|
|
55
|
-
"url": "https://github.com/zdu-strong/mobx-react-use-autorun/issues"
|
|
56
|
-
},
|
|
57
|
-
"publishConfig": {
|
|
58
|
-
"registry": "https://registry.npmjs.org/"
|
|
59
|
-
}
|
|
60
|
-
}
|
|
1
|
+
{"name":"mobx-react-use-autorun","version":"3.0.20","description":"React Hook for mobx","scripts":{"test":"npm install -g typescript@latest @types/node@latest ts-node@latest cross-env@latest && cross-env TS_NODE_SKIP_PROJECT=true ts-node bin/mobx_react_test.ts","build":"npm install -g typescript@latest @types/node@latest ts-node@latest cross-env@latest && cross-env TS_NODE_SKIP_PROJECT=true ts-node bin/mobx_react_build.ts","make":"npm install -g typescript@latest @types/node@latest ts-node@latest cross-env@latest && cross-env TS_NODE_SKIP_PROJECT=true ts-node 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/"}}
|