mobx-react-use-autorun 3.1.23 → 3.1.26

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 +31 -28
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -158,6 +158,32 @@ useUnmount is a lifecycle hook that calls a function when the component will unm
158
158
  return null;
159
159
  })
160
160
 
161
+ ### Define global mutable data with observable
162
+
163
+ import { observable } from 'mobx-react-use-autorun';
164
+
165
+ export const globalState = observable({
166
+ age: 15,
167
+ name: 'tom'
168
+ });
169
+
170
+ export async function setAge(age: number) {
171
+ globalState.age = age
172
+ }
173
+
174
+ import { observer } from "mobx-react-use-autorun";
175
+ import { setAge, globalState } from "./GlobalState";
176
+
177
+ export default observer(() => {
178
+ return <div
179
+ onClick={() => {
180
+ setAge(globalState.age + 1)
181
+ }}
182
+ >
183
+ {`${globalState.name}'s age is ${globalState.age}.`}
184
+ </div>;
185
+ })
186
+
161
187
  ### Get the real data of the proxy object with toJS
162
188
 
163
189
  toJS will cause data to be used, please do not execute toJS(state) in component rendering code, it may cause repeated rendering.<br/>
@@ -207,35 +233,12 @@ Correct Example:<br/>
207
233
  </button>;
208
234
  })
209
235
 
210
- ### Define global mutable data with observable
211
-
212
- import { observable } from 'mobx-react-use-autorun';
213
-
214
- export const globalState = observable({
215
- age: 15,
216
- name: 'tom'
217
- });
218
-
219
- export async function setAge(age: number) {
220
- globalState.age = age
221
- }
222
-
223
- import { observer } from "mobx-react-use-autorun";
224
- import { setAge, globalState } from "./GlobalState";
225
-
226
- export default observer(() => {
227
- return <div
228
- onClick={() => {
229
- setAge(globalState.age + 1)
230
- }}
231
- >
232
- {`${globalState.name}'s age is ${globalState.age}.`}
233
- </div>;
234
- })
235
-
236
236
  # Notes - Work with non-observable components
237
237
 
238
- Non-observable component unable to know data changes, So use toJS to do this.
238
+ Non-observer components cannot trigger re-rendering when the following data changes. Use toJS to do this.<br/>
239
+ array<br/>
240
+ object<br/>
241
+ The all data used in the new render callback<br/>
239
242
 
240
243
  import { observer, toJS, useMobxState } from "mobx-react-use-autorun";
241
244
  import { v1 } from "uuid";
@@ -291,7 +294,7 @@ Typedjson is a strongly typed reflection library.<br/>
291
294
 
292
295
  # Learn More
293
296
 
294
- 1. A JavaScript library for building user interfaces (https://reactjs.org)<br/>
297
+ 1. A JavaScript library for building user interfaces (https://react.dev)<br/>
295
298
  2. Reactive Extensions Library for JavaScript (https://www.npmjs.com/package/rxjs)
296
299
  3. Material UI is a library of React UI components that implements Google's Material Design (https://mui.com)
297
300
 
package/package.json CHANGED
@@ -1 +1 @@
1
- {"name":"mobx-react-use-autorun","version":"3.1.23","description":"Provide concise usage for mobx in react","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.9.0","mobx-react-lite":"3.4.3","react-use":"17.4.0","rxjs":"7.8.0"},"peerDependencies":{"react":">=16.8.0"},"license":"MIT","keywords":["react","mobx","typescript","hooks"],"main":"./dist/cjs/index.js","module":"./dist/esm/index.js","es2015":"./dist/esm/index.js","types":"./dist/cjs/index.d.ts","eslintConfig":{"extends":["react-app","react-app/jest"]},"exports":{".":{"types":"./dist/cjs/index.d.ts","node":"./dist/cjs/index.js","require":"./dist/cjs/index.js","es2015":"./dist/esm/index.js","default":"./dist/esm/index.js"}},"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/"}}
1
+ {"name":"mobx-react-use-autorun","version":"3.1.26","description":"Provide concise usage for mobx in react","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.9.0","mobx-react-lite":"3.4.3","react-use":"17.4.0","rxjs":"7.8.1"},"peerDependencies":{"react":">=16.8.0"},"license":"MIT","keywords":["react","mobx","typescript","hooks"],"main":"./dist/cjs/index.js","module":"./dist/esm/index.js","es2015":"./dist/esm/index.js","types":"./dist/cjs/index.d.ts","eslintConfig":{"extends":["react-app","react-app/jest"]},"exports":{".":{"types":"./dist/cjs/index.d.ts","node":"./dist/cjs/index.js","require":"./dist/cjs/index.js","es2015":"./dist/esm/index.js","default":"./dist/esm/index.js"}},"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/"}}