# use-memoized-callback

> Prevent unnecessary updates with callback memoization

Latest version **0.0.3** (published 2019-10-08) · ISC license · 0 weekly downloads

## Install

```sh
npm install use-memoized-callback
pnpm add use-memoized-callback
yarn add use-memoized-callback
bun add use-memoized-callback
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.3 |
| Published | 2019-10-08 |
| First published | 2019-10-03 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 3.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Saman Mohamadi |
| Maintainers | samanm |
| Keywords | memoization, use-callback, performance, react-hook, react |

## Links

- npm: https://www.npmjs.com/package/use-memoized-callback
- Repository: https://github.com/samanmohamadi/use-memoized-callback
- Homepage: https://github.com/samanmohamadi/use-memoized-callback#readme
- Issues: https://github.com/samanmohamadi/use-memoized-callback/issues
- npm.io page: https://npm.io/package/use-memoized-callback

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 0.0.3 (latest) — 2019-10-08
- 0.0.2 — 2019-10-08
- 0.0.1 — 2019-10-03

## README

# useMemoizedCallback react hook

Install it with yarn:

```
yarn add use-memoized-callback 
```

or with npm:

```
npm i use-memoized-callback  --save
```

**For more information about callback memoization read this [article](https://medium.com/@samanmhd/boost-performance-of-functional-react-components-with-memoized-callbacks-441343a237b7).*

# Example

```javascript
import React, { useState } from 'react';
import useMemoizedCallback  from 'use-memoized-callback '; 


function App(){
  const [counter, setCounter] = useState(0);

  const incCounter = useMemoizedCallback(event => {
    setCounter(counter + 1);
  }); // no dependency required

  return (
    <div>
      {/* 
          incCounter is memoized so AnotherComponent will not reRender each time.
      */}
       <AnotherComponent onClick={incCounter} /> 
    </div>
  );
}

```

---
_Source: https://npm.io/package/use-memoized-callback · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
