# react-memoise

> A component to declaratively memoise a computation within a React component.

Latest version **1.0.2** (published 2018-02-19) · MIT license · 0 weekly downloads

## Install

```sh
npm install react-memoise
pnpm add react-memoise
yarn add react-memoise
bun add react-memoise
```

## Health

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

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.2 |
| Published | 2018-02-19 |
| First published | 2018-02-19 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Node | >=6 |
| Dependencies | 2 |
| Unpacked size | 35.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | yes |
| GitHub stars | 3 |
| Author | Tobias Deekens |
| Maintainers | tdeekens |
| Keywords | react, memoize, memoise, performance |

## Links

- npm: https://www.npmjs.com/package/react-memoise
- Repository: https://github.com/tdeekens/react-memoise
- Homepage: https://github.com/tdeekens/react-memoise#readme
- Issues: https://github.com/tdeekens/react-memoise/issues
- npm.io page: https://npm.io/package/react-memoise

## Dependencies (2)

- [warning](https://npm.io/package/warning.md) ^3.0.0
- [fast-equals](https://npm.io/package/fast-equals.md) ^1.0.6

## 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

- 1.0.2 (latest) — 2018-02-19
- 1.0.1 — 2018-02-19
- 1.0.0 — 2018-02-19

## README

<p align="center">
  <img alt="Logo" src="https://raw.githubusercontent.com/tdeekens/react-memoise/master/logo.jpg" /><br /><br />
</p>

<h2 align="center">📚 react-memoise - declaratively memoise a computation in a React component 🧠</h2>
<p align="center">
  <i>Given a <Memoise> component pass it some props and a computation and it will re-render with a memoised result.</i>
</p>

<p align="center">
  <em>
  ❤️
  React
  · Jest
  · Prettier
  · Flow
  · Enzyme
  · ESLint
  · Babel
  · Rollup
  🙏
  </em>
</p>

<p align="center">
  <a href="https://circleci.com/gh/tdeekens/react-memoise">
    <img alt="CircleCI Status" src="https://circleci.com/gh/tdeekens/react-memoise.svg?style=shield&circle-token=ec2b089c775c53209c334673c8b5cbbc8cf2e8d7">
  </a>
  <a href="https://codecov.io/gh/tdeekens/react-memoise">
    <img alt="Codecov Coverage Status" src="https://img.shields.io/codecov/c/github/tdeekens/react-memoise.svg?style=flat-square">
  </a>
  <img alt="Made with Coffee" src="https://img.shields.io/badge/made%20with-%E2%98%95%EF%B8%8F%20coffee-yellow.svg">
</p>

## Installation

Just `yarn add react-memoise` or `npm i react-memoise`.

## Documentation & Examples

#### Using the Function as a Child pattern

```jsx
import Memoise from 'react-memoise';

const ParentComponent = props => (
  <Memoise args={[props.a, props.b]} compute={(a, b => a * b)}>
    {computedValue => <code>{computedValue}</code>}
  </Memoise>
);
```

#### Using a render-prop

```jsx
import Memoise from 'react-memoise';

const ParentComponent = props => (
  <Memoise
    args={[props.a, props.b]}
    compute={(a, b => a * b)}
    render={computedValue => <code>{computedValue}</code>}
  />
);
```

#### Using a component

```jsx
import Memoise from 'react-memoise';

const ConsumerComponent = props => <code>{props.computedValue}</code>;

const ParentComponent = props => (
  <Memoise
    args={[props.a, props.b]}
    compute={(a, b => a * b)}
    component={ConsumerComponent}
  />
);
```

#### Customization

You can pass in an `areArgsEqual` prop with the signature of `(prevArgs: Args, nextArgs: Args) => boolean` to customise the equality check which defaults to a shallow equal.

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