Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/eclass/usesideeffect
https://github.com/eclass/usesideeffect
Last synced: about 1 month ago
JSON representation
- Host: GitHub
- URL: https://github.com/eclass/usesideeffect
- Owner: eclass
- License: mit
- Created: 2019-11-15T15:09:49.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2024-05-28T08:41:30.000Z (7 months ago)
- Last Synced: 2024-05-29T18:55:03.259Z (7 months ago)
- Language: TypeScript
- Size: 354 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 42
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# @eclass/use-side-effect
[![npm](https://img.shields.io/npm/v/@eclass/use-side-effect.svg)](https://www.npmjs.com/package/@eclass/use-side-effect)
[![Build Status](https://travis-ci.org/eclass/scrollmove.svg?branch=master)](https://travis-ci.org/eclass/scrollmove)
[![downloads](https://img.shields.io/npm/dt/@eclass/use-side-effect.svg)](https://www.npmjs.com/package/@eclass/use-side-effect)
[![dependencies](https://img.shields.io/david/eclass/scrollmove.svg)](https://david-dm.org/eclass/scrollmove)
[![devDependency Status](https://img.shields.io/david/dev/eclass/scrollmove.svg)](https://david-dm.org/eclass/scrollmove#info=devDependencies)> Hook para aplicar un efecto asociado a un objeto
### 🏠 [Homepage](https://github.com/eclass/useSideEffect#readme)
## Prerequisites
- node >=10.16.3
## Install
```sh
npm i @eclass/use-side-effect
```## Run tests
```sh
npm run test
```## Example 📖
`useSideEffect()` receives an initializer parameter and return two elements `[getter, setter]`.
```js
import useSideEffect from "@eclass/use-side-effect";function App() {
const [obj, setObj] = useSideEffect({
name: "pedro",
age: 29
});...
```### Problem / Resolution
When you have an object in your state and use some effect to update this state could make and infinity loop, with this implementation we compare if your object it's same key/value/order and if is it the same don't update your state again.
## Author
👤 **Ender Bonnet**
- Twitter: [@enBonnet](https://twitter.com/enbonnet)
- Github: [@enBonnet](https://github.com/enbonnet)## 📝 License
Copyright © 2019 [Ender Bonnet (https://enbonnet.me/)](https://github.com/eclass).
This project is [MIT](https://github.com/eclass/scrollmove/blob/master/LICENSE) licensed.