useupdateeffect-react-hook
v1.0.5
Published
useUpdateEffect React hook
Downloads
18
Maintainers
Readme
useUpdateEffect()
An useEffect that does not run on the first render
Install
npm install useupdateeffect-react-hook
or
yarn add useupdateeffect-react-hook
Quickstart
import { useState } from "react";
import useUpdateEffect from "useupdateeffect-react-hook";
function App() {
const [count, setCount] = useState(10);
useUpdateEffect(() => alert(count), [count]);
return (
<div>
<div>{count}</div>
<button onClick={() => setCount((c) => c + 1)}>Increment</button>
</div>
);
}
Demo
https://use-update-effect.vercel.app/