Comments (5)
Also here's how I batched my image requests in case anyone needs this:
import {ImageCacheProvider} from 'react-native-cached-image';
import {Promise as Bluebird} from 'bluebird';
function downloadImages(imageUrls) {
var chunks = [];
var chunkSize = 10;
// split large array of image urls into chunks
for (var i = 0, j = imageUrls.length; i < j; i += chunkSize) {
chunks.push(imageUrls.slice(i, i + chunkSize));
}
// I used the Bluebird Promise library to wait for each batch of requests to finish before starting another
return Bluebird.each(chunks, (chunk) => {
return ImageCacheProvider.cacheMultipleImages(chunk);
})
}
from react-native-cached-image.
Hey @sladkoff
Currently we start a prefetch task for each url concurrently and let the underlying native code handle the workload, I think what's happening is that you are overloading it with requests and it runs out of memory.
You could implement you own ImageCacheProvider
to handle this, or you could try calling cacheMultipleImages
with smaller batches
from react-native-cached-image.
Also, we are saving all images to RNFetchBlob.fs.dirs.CacheDir
see docs
I'm not sure if this space is limited.
from react-native-cached-image.
Hey @kfiroo
Thanks for the quick answer.
I'm now batching the requests and it works perfectly.
I read up on the Android cache dir.
It doesn't seem to have limited space but it's still not recommended to store critical data since it may be purged automatically when the device storage runs full.
You should always maintain the cache files yourself and stay within a reasonable limit of space consumed, such as 1MB. When the user uninstalls your application, these files are removed.
Do you think it would be possible to support different storage options in the core project in the future?
For example the component could have an optional prop which defaults to the cache dir. The ImageCacheProvider would also need a customizable option parameter.
I don't really want to maintain a copy of the project and think that the functionality has its uses...
In the meantime I'll try to implement this locally. If it works and you agree, I could open a PR.
What do you think?
from react-native-cached-image.
Try this one!! It works with expo@v25 and Iām using it in my project.
https://hackernoon.com/smart-images-in-react-native-db0ef047dd8c
from react-native-cached-image.
Related Issues (20)
- Not working on the snack.expo.io platform HOT 1
- ImageCachePreloader does not work on first time preloading HOT 2
- The code in example does NOT really clear the cache
- Netinfo error HOT 11
- Open image in modal
- RN 0.60 support HOT 4
- Update TypeScript types to reflect examples. HOT 1
- Change dependency react-native-fetch-blob to rn-fetch-blob as the previous repo has been achieved HOT 2
- componentWillReceiveProps [Deprecated]
- NetInfo is deprecated from react-native use from @community HOT 9
- Replace react-native-fetch-blob with rn-fetch-blob
- Crashes in release on 0.60
- webp support for image?
- netinfo has been removed from react-native HOT 8
- Update Readme HOT 1
- Please remove this issue
- Getting double borders HOT 1
- Error on hermes engine: DocumentDir of null
- separate netinfo from React native & import from react native community
- Import Netinfo from react native community
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
š Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ššš
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ā¤ļø Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-native-cached-image.