mobx-react-use-autorun 3.0.1 → 3.0.2
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/dist/lib/useMobxState.js
CHANGED
|
@@ -4,14 +4,16 @@ export function useMobxState(state, props) {
|
|
|
4
4
|
var _a, _b;
|
|
5
5
|
var mobxState = useLocalObservable(typeof state === "function" ? state : function () { return state; });
|
|
6
6
|
var propsResult = typeof props === "function" ? props() : props;
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
7
|
+
if (propsResult) {
|
|
8
|
+
for (var key in propsResult) {
|
|
9
|
+
if (isObservable(propsResult[key])) {
|
|
10
|
+
mobxState[key] = propsResult[key];
|
|
11
|
+
}
|
|
12
|
+
else {
|
|
13
|
+
if (propsResult[key] !== mobxState[key]) {
|
|
14
|
+
remove(mobxState, key);
|
|
15
|
+
extendObservable(mobxState, (_a = {}, _a[key] = propsResult[key], _a), (_b = {}, _b[key] = false, _b));
|
|
16
|
+
}
|
|
15
17
|
}
|
|
16
18
|
}
|
|
17
19
|
}
|
|
@@ -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,MAAM,MAAM,CAAC;AAC9D,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAErD,MAAM,UAAU,YAAY,CAAyD,KAAQ,EAAE,KAAS;;IAEpG,IAAM,SAAS,GAAG,kBAAkB,CAAC,OAAO,KAAK,KAAK,UAAU,CAAC,CAAC,CAAE,KAAa,CAAC,CAAC,CAAC,cAAM,OAAA,KAAK,EAAL,CAAK,CAAC,CAAC;IAEjG,IAAM,WAAW,GAAG,OAAO,KAAK,KAAK,UAAU,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC;IAElE,KAAK,IAAM,GAAG,IAAI,WAAW,EAAE;
|
|
1
|
+
{"version":3,"file":"useMobxState.js","sourceRoot":"","sources":["../../lib/lib/useMobxState.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,MAAM,CAAC;AAC9D,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAErD,MAAM,UAAU,YAAY,CAAyD,KAAQ,EAAE,KAAS;;IAEpG,IAAM,SAAS,GAAG,kBAAkB,CAAC,OAAO,KAAK,KAAK,UAAU,CAAC,CAAC,CAAE,KAAa,CAAC,CAAC,CAAC,cAAM,OAAA,KAAK,EAAL,CAAK,CAAC,CAAC;IAEjG,IAAM,WAAW,GAAG,OAAO,KAAK,KAAK,UAAU,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC;IAElE,IAAG,WAAW,EAAC;QACX,KAAK,IAAM,GAAG,IAAI,WAAW,EAAE;YAC3B,IAAI,YAAY,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,EAAE;gBAChC,SAAS,CAAC,GAAG,CAAC,GAAG,WAAW,CAAC,GAAG,CAAC,CAAC;aACrC;iBAAM;gBACH,IAAI,WAAW,CAAC,GAAG,CAAC,KAAK,SAAS,CAAC,GAAG,CAAC,EAAE;oBACrC,MAAM,CAAC,SAAS,EAAE,GAAG,CAAC,CAAC;oBACvB,gBAAgB,CAAC,SAAS,YAAI,GAAC,GAAG,IAAG,WAAW,CAAC,GAAG,CAAC,iBAAM,GAAC,GAAG,IAAG,KAAK,MAAG,CAAA;iBAC7E;aACJ;SACJ;KACJ;IAED,OAAO,SAAgB,CAAC;AAC5B,CAAC"}
|
package/lib/index.d.ts
CHANGED
|
@@ -2,5 +2,6 @@ declare function useMobxState<T extends Record<any, any>, P extends Record<any,
|
|
|
2
2
|
declare function useMobxState<T extends Record<any, any>, P extends Record<any, any>>(statefn: () => T, propsfn: () => P): T & P;
|
|
3
3
|
declare function useMobxState<T extends Record<any, any>, P extends Record<any, any>>(statefn: () => T, props?: P): T & P;
|
|
4
4
|
declare function useMobxState<T extends Record<any, any>, P extends Record<any, any>>(state: T, propsfn: () => P): T & P;
|
|
5
|
-
|
|
5
|
+
declare function useMobxState<T extends Record<any, any>>(state: T): T;
|
|
6
|
+
declare function useMobxState<T extends Record<any, any>>(statefn: () => T): T;
|
|
6
7
|
export { useMobxState };
|
package/lib/lib/useMobxState.tsx
CHANGED
|
@@ -7,13 +7,15 @@ export function useMobxState<T extends Record<any, any>, P extends Record<any, a
|
|
|
7
7
|
|
|
8
8
|
const propsResult = typeof props === "function" ? props() : props;
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
10
|
+
if(propsResult){
|
|
11
|
+
for (const key in propsResult) {
|
|
12
|
+
if (isObservable(propsResult[key])) {
|
|
13
|
+
mobxState[key] = propsResult[key];
|
|
14
|
+
} else {
|
|
15
|
+
if (propsResult[key] !== mobxState[key]) {
|
|
16
|
+
remove(mobxState, key);
|
|
17
|
+
extendObservable(mobxState, { [key]: propsResult[key] }, { [key]: false })
|
|
18
|
+
}
|
|
17
19
|
}
|
|
18
20
|
}
|
|
19
21
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mobx-react-use-autorun",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.2",
|
|
4
4
|
"description": "React Hook for mobx",
|
|
5
5
|
"scripts": {
|
|
6
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",
|