use-update-effect-hook
TypeScript icon, indicating that this package has built-in type declarations

0.1.1 • Public • Published

useUpdateEffect()

An useEffect that does not run on the first render

Install

npm install use-update-effect-hook

or

yarn add use-update-effect-hook

Quickstart

import { useState } from "react";
import useUpdateEffect from "use-update-effect-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/

Package Sidebar

Install

npm i use-update-effect-hook

Weekly Downloads

11

Version

0.1.1

License

MIT

Unpacked Size

8.08 kB

Total Files

12

Last publish

Collaborators

  • roya4sh