mobx-react-use-autorun 4.0.21 → 4.0.23

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 +9 -13
  2. package/package.json +3 -3
package/README.md CHANGED
@@ -11,20 +11,16 @@ Provide concise usage for mobx in react<br/>
11
11
  import { useMobxState, observer } from 'mobx-react-use-autorun';
12
12
  import { useRef } from 'react';
13
13
 
14
- export default observer((props: {name: string}) => {
14
+ export default observer((props: { name: string }) => {
15
15
 
16
16
  const state = useMobxState({
17
17
  age: 16
18
- }, {
19
- ...props,
20
- divRef: useRef<any>()
21
18
  });
22
19
 
23
20
  return <div
24
- ref={state.divRef}
25
21
  onClick={() => state.age++}
26
22
  >
27
- {`${state.name}'s age is ${state.age}`}
23
+ {`${props.name}'s age is ${state.age}`}
28
24
  </div>
29
25
  })
30
26
 
@@ -112,7 +108,9 @@ More example - Form validation:<br/>
112
108
 
113
109
  export default observer(() => {
114
110
 
115
- const state = useMobxState({ randomNumber: 1 });
111
+ const state = useMobxState({
112
+ randomNumber: 1
113
+ });
116
114
 
117
115
  useMobxEffect(() => {
118
116
  console.log(toJS(state))
@@ -149,6 +147,7 @@ Strict Mode: In the future, React will provide a feature that lets components pr
149
147
 
150
148
  ### Define global mutable data with observable
151
149
 
150
+ // File: GlobalState.tsx
152
151
  import { observable } from 'mobx-react-use-autorun';
153
152
 
154
153
  export const globalState = observable({
@@ -156,17 +155,14 @@ Strict Mode: In the future, React will provide a feature that lets components pr
156
155
  name: 'tom'
157
156
  });
158
157
 
159
- export async function setAge(age: number) {
160
- globalState.age = age
161
- }
162
-
158
+ // File: UserComponent.tsx
163
159
  import { observer } from "mobx-react-use-autorun";
164
- import { setAge, globalState } from "./GlobalState";
160
+ import { globalState } from "./GlobalState";
165
161
 
166
162
  export default observer(() => {
167
163
  return <div
168
164
  onClick={() => {
169
- setAge(globalState.age + 1)
165
+ globalState.age++;
170
166
  }}
171
167
  >
172
168
  {`${globalState.name}'s age is ${globalState.age}.`}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mobx-react-use-autorun",
3
- "version": "4.0.21",
3
+ "version": "4.0.23",
4
4
  "description": "Provide concise usage for mobx in react",
5
5
  "scripts": {
6
6
  "test": "npx -y -p typescript -p ts-node ts-node --skipProject bin/mobx_react_test.ts",
@@ -8,8 +8,8 @@
8
8
  "make": "npx -y -p typescript -p ts-node ts-node --skipProject bin/mobx_react_make.ts"
9
9
  },
10
10
  "dependencies": {
11
- "mobx": "6.12.0",
12
- "mobx-react-lite": "4.0.6",
11
+ "mobx": "6.12.3",
12
+ "mobx-react-lite": "4.0.7",
13
13
  "rxjs": "7.8.1"
14
14
  },
15
15
  "peerDependencies": {