mobx-react-lite
Advanced tools
Comparing version 0.3.2 to 0.3.3
{ | ||
"name": "mobx-react-lite", | ||
"version": "0.3.2", | ||
"version": "0.3.3", | ||
"description": "Lightweight React bindings for MobX based on experimental React hooks", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -21,3 +21,3 @@ # mobx-react-lite <!-- omit in toc --> | ||
- [`useComputed(func: () => T, inputs: ReadonlyArray<any> = []): T`](#usecomputedfunc---t-inputs-readonlyarrayany---t) | ||
- [`useObservableEffect<D extends IReactionDisposer>(disposerGenerator: () => D, inputs: ReadonlyArray<any> = []): D`](#useobservableeffectd-extends-ireactiondisposerdisposergenerator---d-inputs-readonlyarrayany---d) | ||
- [`useDisposable<D extends IReactionDisposer>(disposerGenerator: () => D, inputs: ReadonlyArray<any> = []): D`](#usedisposabled-extends-ireactiondisposerdisposergenerator---d-inputs-readonlyarrayany---d) | ||
- [Server Side Rendering with `useStaticRendering`](#server-side-rendering-with-usestaticrendering) | ||
@@ -206,5 +206,5 @@ - [Why no Provider/inject?](#why-no-providerinject) | ||
### `useObservableEffect<D extends IReactionDisposer>(disposerGenerator: () => D, inputs: ReadonlyArray<any> = []): D` | ||
### `useDisposable<D extends IReactionDisposer>(disposerGenerator: () => D, inputs: ReadonlyArray<any> = []): D` | ||
Adds an observable (Mobx) effect (`reaction`, `autorun`, `when`, or anything else that returns a disposer) that will be registered upon component creation and disposed upon unmounting. | ||
The disposable is any kind of function that returns another function to be called on a component unmount to clean up used resources. Use MobX related functions like [`reaction`](https://mobx.js.org/refguide/reaction.html), [`autorun`](https://mobx.js.org/refguide/autorun.html), [`when`](https://mobx.js.org/refguide/when.html), [`observe`](https://mobx.js.org/refguide/observe.html), or anything else that returns a disposer. | ||
Returns the generated disposer for early disposal. | ||
@@ -215,3 +215,3 @@ | ||
```typescript | ||
import { observer, useComputed, useObservableEffect } from "mobx-react-lite" | ||
import { observer, useComputed, useDisposable } from "mobx-react-lite" | ||
@@ -225,3 +225,3 @@ const Name = observer((props: { firstName: string; lastName: string }) => { | ||
// when the name changes then send this info to the server | ||
useObservableEffect(() => | ||
useDisposable(() => | ||
reaction( | ||
@@ -228,0 +228,0 @@ () => fullName, |
Deprecated
MaintenanceThe maintainer of the package marked it as deprecated. This could indicate that a single version should not be used, or that the package is no longer maintained and any new vulnerabilities will not be fixed.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Trivial Package
Supply chain riskPackages less than 10 lines of code are easily copied into your own project and may not warrant the additional supply chain risk of an external dependency.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
1
212763
7
10
1
2