# react-native-expo-image-cache

> React Native Image Cache and Progressive Loading based on Expo

Latest version **4.1.0** (published 2019-11-14) · MIT license · 0 weekly downloads

## Install

```sh
npm install react-native-expo-image-cache
pnpm add react-native-expo-image-cache
yarn add react-native-expo-image-cache
bun add react-native-expo-image-cache
```

## Health

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

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 4.1.0 |
| Published | 2019-11-14 |
| First published | 2018-01-28 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 34.4 KB |
| Known vulnerabilities | 0 (+2 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 683 |
| Author | William Candillon |
| Maintainers | wcandillon |
| Keywords | react, image, cache |

## Links

- npm: https://www.npmjs.com/package/react-native-expo-image-cache
- Repository: https://github.com/wcandillon/react-native-expo-image-cache
- Homepage: https://github.com/wcandillon/react-native-expo-image-cache#readme
- Issues: https://github.com/wcandillon/react-native-expo-image-cache/issues
- npm.io page: https://npm.io/package/react-native-expo-image-cache

## Dependencies (2)

- [lodash](https://npm.io/package/lodash.md) ^4.17.4
- [crypto-js](https://npm.io/package/crypto-js.md) ^3.1.9-1

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

- 4.1.0 (latest) — 2019-11-14
- 4.0.8 — 2019-08-11
- 4.0.7 — 2019-08-10
- 4.0.6 — 2019-08-05
- 4.0.4 — 2019-06-17
- 4.0.3 — 2019-06-17
- 4.0.2 — 2019-06-16
- 4.0.1 — 2019-06-16
- 4.0.0 — 2019-06-16
- 3.2.0 — 2018-09-06
- 3.1.1 — 2018-06-04
- 3.1.0 — 2018-06-04
- 3.0.3 — 2018-05-02
- 3.0.2 — 2018-04-20
- 3.0.1 — 2018-04-12
- … 19 more at https://npm.io/package/react-native-expo-image-cache/versions

## README

# React Native Image Cache and Progressive Loading


[![CircleCI](https://circleci.com/gh/wcandillon/react-native-expo-image-cache.svg?style=svg)](https://circleci.com/gh/wcandillon/react-native-expo-image-cache)
[![npm version](https://badge.fury.io/js/react-native-expo-image-cache.svg)](https://badge.fury.io/js/react-native-expo-image-cache)

React Native image cache and progressive loading for iOS and Android. Based on Expo Kit.

This is a component used in the [React Native Elements](https://react-native.shop/#elements) and the [React Native Fiber](https://react-native.shop/#fiber) starter kits.

<img src="https://firebasestorage.googleapis.com/v0/b/react-native-e.appspot.com/o/2018-01-28%2017_36_46.gif?alt=media&token=6afaef74-454d-4c04-85ab-be410d0b225b" />

Checkout this [medium story about react-native-expo-image-cache](https://medium.com/@wcandillon/5-things-to-know-about-images-react-native-69be41d2a9ee).

## Installation

This package has a peer dependency with React, React Native, and Expo.

```
yarn add react-native-expo-image-cache
```

## Usage

### Props

| Props        | Default     | Options  |
| ------------- |:-------------:| -----:|
| tint      | dark | light, dark, default |
| transitionDuration     | 300      | custom in ms |


### <Image>

```js
import {Image} from "react-native-expo-image-cache";

// preview can be a local image or a data uri
const preview = { uri: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+M9QDwADhgGAWjR9awAAAABJRU5ErkJggg==" };
const uri = "https://firebasestorage.googleapis.com/v0/b/react-native-e.appspot.com/o/b47b03a1e22e3f1fd884b5252de1e64a06a14126.png?alt=media&token=d636c423-3d94-440f-90c1-57c4de921641";
<Image style={{ height: 100, width: 100 }} {...{preview, uri}} />
```

### CacheManager

Get the local image from a remote URI

```js
import {CacheManager} from "react-native-expo-image-cache";

const {uri} = this.props;
const path = await CacheManager.get(uri).getPath();
// if path is undefined, the image download has failed 
```

You can also clear the local cache:

```js

import {CacheManager} from "react-native-expo-image-cache";

await CacheManager.clearCache();
```

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