Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/leaysgur/mobx-preact-super-lite
Super lightweight Preact bindings for MobX based on Preact 10.x+ and Hooks
https://github.com/leaysgur/mobx-preact-super-lite
Last synced: 24 days ago
JSON representation
Super lightweight Preact bindings for MobX based on Preact 10.x+ and Hooks
- Host: GitHub
- URL: https://github.com/leaysgur/mobx-preact-super-lite
- Owner: leaysgur
- License: mit
- Created: 2020-08-12T09:29:25.000Z (about 4 years ago)
- Default Branch: master
- Last Pushed: 2020-10-18T07:35:06.000Z (about 4 years ago)
- Last Synced: 2024-09-28T13:45:59.711Z (about 1 month ago)
- Language: TypeScript
- Homepage:
- Size: 54.7 KB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# mobx-preact-super-lite
Super lightweight Preact bindings for MobX based on Preact 10.x+ and Hooks.
[![NPM](https://nodei.co/npm/mobx-preact-super-lite.png)](https://www.npmjs.com/package/mobx-preact-super-lite)
Base version is aligned with `mobx-react-lite` version.
## Motivation
For now Preact app to use MobX, we need `preact/compat`(not just `preact`) and bundler alias.
But for bundle size, I want to use MobX with `preact`.
So, I've just copied `mobx-react-lite` package and added some tweaks.
With this package, you can use minimum `preact` package and limited `mobx-react-lite` APIs.
## Compatibility
Roughly speaking, `mobx-preact-super-lite` = `mobx-react-lite` - `observer()` hoc.
| API | mobx-react-lite | mobx-preact-super-lite |
| ----------------------- |:---------------:|:----------------------:|
| observer() | ✅ | (*1) |
| \ | ✅ | ✅ |
| useLocalObservable() | ✅ | ✅ |
| enableStaticRendering() | ✅ | ✅ |- \*1 Original implementation requires `memo()` and `forwardRef()`, it means `preact/compat` is needed.
### Deprecated APIs
| API | mobx-react-lite | mobx-preact-super-lite |
| ------------------------ |:---------------:|:----------------------:|
| useObserver() | ✅ | ✅ |
| useLocalStore() | ✅ | ✅ |
| useAsObservableSource() | ✅ | ✅ |
| observerBatching() | ✅ | (*2) |
| observerBatchingOptOut() | ✅ | (*2) |
| isObserverBatched() | ✅ | (*2) |- \*2 We opt it out automatically.
## API reference
See original [repository](https://github.com/mobxjs/mobx-react-lite) and [user guide](https://mobx.js.org/react-integration.html).