Hook para aplicar un efecto asociado a un objeto
🏠 Homepage
- node >=10.16.3
npm i @eclass/use-side-effect
npm run test
useSideEffect()
receives an initializer parameter and return two elements [getter, setter]
.
import useSideEffect from "@eclass/use-side-effect";
function App() {
const [obj, setObj] = useSideEffect({
name: "pedro",
age: 29
});
...
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.
👤 Ender Bonnet
Copyright © 2019 Ender Bonnet [email protected] (https://enbonnet.me/).
This project is MIT licensed.