You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Apr 15, 2025. It is now read-only.
Copy file name to clipboardExpand all lines: README.md
+68-79Lines changed: 68 additions & 79 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,9 +9,9 @@ React Native Higher Order Component that adds advanced caching functionality to
9
9
10
10
## Features
11
11
12
-
***Drop in Replacement** for native \<Image\> component.
13
-
***Automatically Cache** remote image files to local filesystem to increase performance.
14
-
***Automatically Persist** remote image files to local filesystem _forever_ with a simple component prop flag.
12
+
-**Drop in Replacement** for native \<Image\> component.
13
+
-**Automatically Cache** remote image files to local filesystem to increase performance.
14
+
-**Automatically Persist** remote image files to local filesystem _forever_ with a simple component prop flag.
15
15
16
16
## Installation
17
17
@@ -37,45 +37,43 @@ To troubleshoot linking, refer to [the react-native-fs installation instructions
37
37
38
38
## Usage
39
39
40
-
React Native Image Cache HOC creates an advanced image component, \<CacheableImage\>, that is a drop in replacement for the standard \<Image\> component.
40
+
React Native Image Cache HOC creates an advanced image component, \<CacheableImage\>, that is a drop in replacement for the standard \<Image\> component.
41
41
42
42
**Differences between the advanced image component and standard image component API are as follows:**
43
43
44
44
1.**Modified "source" Prop:** The advanced component "source" prop only accepts a web accessible url (there's no reason to use this library to render files that already exist on the local filesystem), and it does NOT accept an array of urls.
45
45
2.**New "permanent" Prop:** The new, optional (defaults to False), "permanent" prop determines if the image file should be stored forever on the local filesystem instead of written to a temperary cache that is subject to occasional pruning.
46
-
3.**New "placeholder" Prop:** The new, optional (defaults to standard Image component), "placeholder" prop determines component to render while remote image file is downloading.
46
+
3.**New "placeholder" Prop:** The new, optional (defaults to standard Image component), "placeholder" prop determines component to render while remote image file is downloading.
47
47
48
48
**TL;DR: To cache image files for performance, simply use \<CacheableImage\> as a drop in replacement for \<Image\>. To store files permanently add a permanent={true} prop to \<CacheableImage\>.**
// This placeholder object will be used as a placeholder component for all instances of <CacheableImage>
175
+
// This placeholder object will be used as a placeholder component for all instances of <CacheableImage>
181
176
// unless individual <CacheableImage> uses "placeholder" prop to override this default.
182
177
constdefaultPlaceholderObject= {
183
178
component: ActivityIndicator,
@@ -222,35 +217,32 @@ The CacheableImage class returned by React Native Image Cache HOC includes a cou
222
217
Use this method if you need to download a file to the local filesystem prior to rendering \<CacheableImage\> for some reason (perhaps to pre-warm the local cache). If calling this method repeatedly to cache a long list of files, be sure to use a queue and limit concurrency so your app performance does not suffer.
// The https://i.redd.it/hhhim0kc5swz.jpg remote file is now saved to local fs permanently.
231
+
})
239
232
```
240
233
241
234
**CacheableImage.flush()**
242
235
243
236
Delete all locally stored image files created by react-native-image-cache-hoc (cache AND permanent). Calling this method will cause a performance hit on your app until the local files are rebuilt.
iOS only allows requests to https urls. If you need to load image files using http you will need to make additional react native config changes.
285
274
286
275
> By default, iOS will block any request that's not encrypted using SSL. If you need to fetch from a cleartext URL (one that begins with http) you will first need to add an App Transport Security exception. If you know ahead of time what domains you will need access to, it is more secure to add exceptions just for those domains; if the domains are not known until runtime you can disable ATS completely. Note however that from January 2017, Apple's App Store review will require reasonable justification for disabling ATS.
0 commit comments