mobx-react-use-autorun 3.1.8 → 3.1.9

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 +34 -34
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -6,7 +6,7 @@ Provide concise usage for mobx in react<br/>
6
6
 
7
7
  # `Usage`
8
8
 
9
- ### Usage - Define state and props with useMobxState
9
+ ### Define state and props with useMobxState
10
10
 
11
11
  import { useMobxState, observer } from 'mobx-react-use-autorun';
12
12
  import { useRef } from 'react';
@@ -110,7 +110,7 @@ The second:
110
110
 
111
111
  Provide a method to generate state, the state is executed only once, and the performance is better.<br/>
112
112
 
113
- ### Usage - Subscription property changes with useMobxEffect
113
+ ### Subscription property changes with useMobxEffect
114
114
 
115
115
  import { useMobxState, observer } from 'mobx-react-use-autorun';
116
116
  import { useMobxEffect, toJS } from 'mobx-react-use-autorun'
@@ -128,7 +128,37 @@ Provide a method to generate state, the state is executed only once, and the per
128
128
  </div>
129
129
  })
130
130
 
131
- ### Usage - Get the real data of the proxy object with toJS
131
+ ### Lifecycle hooks
132
+
133
+ useMount is executed when the component loaded.<br/>
134
+ useUnmount is executed when the component is unmount.<br/>
135
+
136
+ import { Subscription, of, tap } from 'rxjs'
137
+ import { useMobxState, observer } from 'mobx-react-use-autorun'
138
+ import { useMount, useUnmount } from 'mobx-react-use-autorun'
139
+
140
+ export default observer(() => {
141
+
142
+ const state = useMobxState({
143
+ subscription: new Subscription()
144
+ })
145
+
146
+ useMount(() => {
147
+ state.subscription.add(of(null).pipe(
148
+ tap(() => {
149
+ console.log('component is loaded')
150
+ })
151
+ ).subscribe())
152
+ })
153
+
154
+ useUnmount(() => {
155
+ state.subscription.unsubscribe()
156
+ })
157
+
158
+ return null;
159
+ })
160
+
161
+ ### Get the real data of the proxy object with toJS
132
162
 
133
163
  toJS will cause data to be used, please do not execute toJS(state) in component rendering code, it may cause repeated rendering.<br/>
134
164
  Wrong Usage Demonstration:<br/>
@@ -169,7 +199,7 @@ Correct Example:<br/>
169
199
  return <button onClick={() => console.log(toJS(state))}>{'Click Me'}</button>;
170
200
  })
171
201
 
172
- ### Usage - Define global mutable data with observable
202
+ ### Define global mutable data with observable
173
203
 
174
204
  import { observable } from 'mobx-react-use-autorun';
175
205
 
@@ -195,36 +225,6 @@ Correct Example:<br/>
195
225
  </div>;
196
226
  })
197
227
 
198
- ### Usage - Lifecycle hooks
199
-
200
- useMount is executed when the component loaded.<br/>
201
- useUnmount is executed when the component is unmount.<br/>
202
-
203
- import { Subscription, of, tap } from 'rxjs'
204
- import { useMobxState, observer } from 'mobx-react-use-autorun'
205
- import { useMount, useUnmount } from 'mobx-react-use-autorun'
206
-
207
- export default observer(() => {
208
-
209
- const state = useMobxState({
210
- subscription: new Subscription()
211
- })
212
-
213
- useMount(() => {
214
- state.subscription.add(of(null).pipe(
215
- tap(() => {
216
- console.log('component is loaded')
217
- })
218
- ).subscribe())
219
- })
220
-
221
- useUnmount(() => {
222
- state.subscription.unsubscribe()
223
- })
224
-
225
- return null;
226
- })
227
-
228
228
  # Learn More
229
229
 
230
230
  1. React UI framework (https://reactjs.org)<br/>
package/package.json CHANGED
@@ -1 +1 @@
1
- {"name":"mobx-react-use-autorun","version":"3.1.8","description":"React Hook for mobx","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.8.0","mobx-react-lite":"3.4.0","react-use":"17.4.0","rxjs":"7.8.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/"}}
1
+ {"name":"mobx-react-use-autorun","version":"3.1.9","description":"React Hook for mobx","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.8.0","mobx-react-lite":"3.4.0","react-use":"17.4.0","rxjs":"7.8.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/"}}