Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@remobile/react-native-cache-image

Package Overview
Dependencies
Maintainers
2
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@remobile/react-native-cache-image

A cache-image for react-native

  • 1.0.7
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
2
Created
Source

React Native CacheImage (remobile)

A cache-image for react-native
  • When use web image, this module will find the web image's url corresponding image file is exist or not, if exist, it will use local exist file, and check this CacheImage's old url and new url, if old url is the same as new url, do noting. if not, sub old url's ref and add new url's ref, if old url's ref is 0, delete old url corresponding image file.
  • it also will check total storage, total storage is 1024102450, when local file total size is above total storage, it will delete the oldest local file and clear corresponding record.

Installation

npm install @remobile/react-native-cache-image --save

Usage

Example

'use strict';

var React = require('react');
var ReactNative = require('react-native');
var {
    StyleSheet,
    View,
} = ReactNative;

var CacheImage = require('@remobile/react-native-cache-image');

var SERVER = 'http://192.168.1.117:3000/';

module.exports = React.createClass({
    render: function() {
        return (
            <View style={styles.container}>
                <CacheImage
                    resizeMode='stretch'
                    defaultSource={app.img.tabnav_list}
                    url={SERVER+"1.png"}
                    style={styles.image}
                    />
                <CacheImage
                    resizeMode='stretch'
                    defaultSource={app.img.tabnav_list}
                    url={SERVER+"2.png"}
                    style={styles.image}
                    />
                <CacheImage
                    resizeMode='stretch'
                    defaultSource={app.img.tabnav_list}
                    url={SERVER+"3.png"}
                    style={styles.image}
                    />
            </View>
        );
    }
});

var styles = StyleSheet.create({
    container: {
        flex: 1,
        justifyContent: 'center',
        alignItems: 'center',
        backgroundColor: '#F5FCFF',
    },
    image: {
        width:200,
        height:200,
    }
});
Props

This module supports react-native Image's props all.

  • defaultSource : PropTypes.string.isRequired - local image for default image
  • url : PropTypes.string.isRequired - the url of web image
    • format: 'http://{server}/{name}.png' or 'http://{server}/{name}.jpg'
    • must have jpg or png suffix
    • {name} must have version. e.g: first version is verison1.jpg, when you want to update image, you can use verison2.jpg, otherwise this module will not download image

Keywords

FAQs

Package last updated on 13 Mar 2019

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