Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/remobile/react-native-cache-image
https://github.com/remobile/react-native-cache-image
Last synced: 28 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/remobile/react-native-cache-image
- Owner: remobile
- License: mit
- Created: 2015-11-17T08:52:34.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2019-03-13T03:19:18.000Z (almost 6 years ago)
- Last Synced: 2024-10-28T22:41:58.125Z (about 2 months ago)
- Language: JavaScript
- Size: 22.5 KB
- Stars: 161
- Watchers: 5
- Forks: 20
- Open Issues: 11
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-react-native - react-native-cache-image ★158 - A cache-image for react-native (Components / UI)
- awesome-react-native - react-native-cache-image ★158 - A cache-image for react-native (Components / UI)
- awesome-react-native - react-native-cache-image ★158 - A cache-image for react-native (Components / UI)
- awesome-react-native-ui - react-native-cache-image ★115 - A cache-image for react-native (Components / UI)
- awesome-react-native - react-native-cache-image ★158 - A cache-image for react-native (Components / UI)
README
# 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 1024*1024*50, when local file total size is above total storage, it will delete the oldest local file and clear corresponding record.## Installation
```sh
npm install @remobile/react-native-cache-image --save
```
## Usage### Example
```js
'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 (
);
}
});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