An open API service indexing awesome lists of open source software.

https://github.com/tdeekens/react-memoise

A component to declaratively memoise a computation within a React component.
https://github.com/tdeekens/react-memoise

javascript performance react web

Last synced: about 1 month ago
JSON representation

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

Awesome Lists containing this project

README

          


Logo


📚 react-memoise - declaratively memoise a computation in a React component 🧠



Given a component pass it some props and a computation and it will re-render with a memoised result.



❤️
React
· Jest
· Prettier
· Flow
· Enzyme
· ESLint
· Babel
· Rollup
🙏



CircleCI Status


Codecov Coverage Status

Made with Coffee

## 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 => (
a * b}>
{computedValue => {computedValue}}

);
```

#### Using a render-prop

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

const ParentComponent = props => (
a * b}
render={computedValue => {computedValue}}
/>
);
```

#### Using a component

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

const ConsumerComponent = props => {props.computedValue};

const ParentComponent = props => (
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.