New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

react-native-image-cache-wrapper

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-native-image-cache-wrapper

The best react native image cache wrapper.

  • 1.0.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
87
decreased by-30.95%
Maintainers
1
Weekly downloads
 
Created
Source

react-native-image-cache-wrapper

npm

The best react native image cache wrapper.

Feature

  • the same usage with <Image/> and <ImageBackground/>
  • can set activity indicator
  • cache images with expiration
  • clear one cache or all cache files
  • support getSize() and prefetch()
  • support cache base64 data to local

Installation

We use react-native-fetch-blob to handle file system access in this package, So you should install react-native-image-cache-wrapper and react-native-fetch-blob both.

npm install react-native-image-cache-wrapper --save

npm install react-native-fetch-blob --save
react-native link react-native-fetch-blob

or use yarn

yarn add react-native-image-cache-wrapper
yarn add react-native-fetch-blob

ChangeLog

v1.0.0

  1. initial release

Configuration

PropertyTypeDefaultDescriptionFirstRelease
<Image/> or <ImageBackground> propertiessame with <Image/> and <ImageBackground/>1.0
expirationnumber604800expiration seconds (0:no expiration, default cache a week)1.0
activityIndicatorComponentnullwhen loading show it as an indicator, you can use your component1.0

Usage

import CachedImage from 'react-native-image-cache-wrapper';

render()
{
    return (

            <View>
                <CachedImage source={{uri:"https://assets-cdn.github.com/images/modules/logos_page/Octocat.png"}}/>
                <CachedImage source={{uri:"https://assets-cdn.github.com/images/modules/logos_page/Octocat.png"}}/>
                    <Text>This is example with image background.</Text>
                </CachedImage>
            </View>
        );
}

Static Function

CachedImage.getSize(url, success=(width,height)=>void,fail=(error)=>void)

Get the image size, if no cache, will cache it.

Example:

import CachedImage from 'react-native-image-cache-wrapper';

CachedImage.getSize("https://assets-cdn.github.com/images/modules/logos_page/Octocat.png", 
    (width,height)=>{
        console.log("width:"+width+" height:"+height);
    },(error)=>{
        console.log("error:"+error);
    });

CachedImage.prefetch(url,expiration=0,success=(cachFile)=>void,fail=(error)=>void)

prefetch an image and cache it.

Example:

import CachedImage from 'react-native-image-cache-wrapper';

// prefetch and cache image 3600 seconds
CachedImage.prefetch("https://assets-cdn.github.com/images/modules/logos_page/Octocat.png", 3600, 
    (cacheFile)=>{
        console.log("cache filename:"+cacheFile);
    },(error)=>{
        console.log("error:"+error);
    });

CachedImage.deleteCache(url)

delete a cache file.

Example:

import CachedImage from 'react-native-image-cache-wrapper';

// prefetch and cache image 3600 seconds
CachedImage.deleteCache("https://assets-cdn.github.com/images/modules/logos_page/Octocat.png");

CachedImage.clearCache()

clear all cache.

Example:

import CachedImage from 'react-native-image-cache-wrapper';

// prefetch and cache image 3600 seconds
CachedImage.clearCache();

Keywords

FAQs

Package last updated on 11 Jun 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc