Skip to content

Repository files navigation

@eclass/use-side-effect

npmBuild StatusdownloadsdependenciesdevDependency Status

Hook para aplicar un efecto asociado a un objeto

Prerequisites

  • node >=10.16.3

Install

npm i @eclass/use-side-effect

Run tests

npm run test

Example 📖

useSideEffect() receives an initializer parameter and return two elements [getter, setter].

importuseSideEffectfrom"@eclass/use-side-effect";functionApp(){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

📝 License

Copyright © 2019 Ender Bonnet enbonnet@pm.me (https://enbonnet.me/).
This project is MIT licensed.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages