mobx-react-use-autorun 3.0.10 → 3.0.17

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 CHANGED
@@ -110,4 +110,4 @@ Form validation<br/>
110
110
 
111
111
  ## License
112
112
 
113
- This project is licensed under the terms of the [MIT license](/LICENSE.md).
113
+ This project is licensed under the terms of the [MIT license](./LICENSE).
@@ -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[key] = propsResult[key];
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;;QACR,IAAM,WAAW,GAAG,OAAO,KAAK,KAAK,UAAU,CAAC,CAAC,CAAE,KAAa,EAAE,CAAC,CAA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,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"}
@@ -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[key] = propsResult[key];
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,6 +1,6 @@
1
1
  {
2
2
  "name": "mobx-react-use-autorun",
3
- "version": "3.0.10",
3
+ "version": "3.0.17",
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",
@@ -10,23 +10,24 @@
10
10
  "dependencies": {
11
11
  "mobx": ">=6.5.0",
12
12
  "mobx-react-lite": ">=3.3.0",
13
- "react-use": ">=17.3.2"
13
+ "react-use": ">=17.3.2",
14
+ "rxjs": ">=6.0.0"
14
15
  },
15
16
  "peerDependencies": {
16
17
  "react": ">=16.8.0"
17
18
  },
18
19
  "devDependencies": {
19
- "@types/node": "17.0.31",
20
- "@types/react": "17.0.44",
21
- "typescript": "4.6.4",
22
20
  "@testing-library/jest-dom": "5.16.4",
23
21
  "@testing-library/react": "12.1.5",
24
22
  "@testing-library/user-event": "13.5.0",
25
23
  "@types/jest": "27.5.0",
24
+ "@types/node": "17.0.31",
25
+ "@types/react": "17.0.44",
26
26
  "@types/react-dom": "18.0.3",
27
27
  "react": "17.0.2",
28
28
  "react-dom": "17.0.2",
29
- "react-scripts": "5.0.1"
29
+ "react-scripts": "5.0.1",
30
+ "typescript": "4.6.4"
30
31
  },
31
32
  "license": "MIT",
32
33
  "keywords": [
@@ -57,4 +58,4 @@
57
58
  "publishConfig": {
58
59
  "registry": "https://registry.npmjs.org/"
59
60
  }
60
- }
61
+ }