Library for handling data caching for React Native with expo-file-system.
The logic of work is based on a bunch: Manager-Entry. Where manager is an abstraction over a directory within a filesystem, and entry is a file instance within that directory.
Distinctive features:
This library contains the following:
This library is suitable for both small projects and large ones that require their own implementation of the cache.
npx expo install expo-file-system expo-cache-manager
If you plan to use image or progress indicator components, then you need to install additional dependencies
npx expo install expo-image react-native-svg
yarn add expo-file-system expo-cache-manager
# or
npm i expo-file-system expo-cache-manager
Follow the instructions to install expo-file-system package.
If you plan to use image or progress indicator components, then you need to install additional dependencies
yarn add react-native-svg expo-image
# or
npm i react-native-svg expo-image
Follow the instructions to install expo-image package. Follow the instructions to install react-native-svg package.
import { CacheManagerProvider, CachingImage } from 'expo-cache-manager'
export default function App() {
return (
<CacheManagerProvider
managers={[
{
name: 'images',
entryExpiresIn: 30 * 24 * 60 * 60 // 1 month (in seconds)
},
{ name: 'videos' }, // without expire prop (-1 default)
'other' // short naming (-1 default)
]}
>
<CachingImage
uri={'remote-file-uri'}
manager='images'
style={{ width: '100%', height: 300 }}
// placeholder="LEHV6nWB2yk8pyo0adR*.7kCMdnj" // blurhash support
// disabledActions=['pause', 'resume', 'download'] // default []
// automatic // automatically start download. Default = true
// indicator={false} // hide progress indicator
// onProgress={(v) => console.log(`${v}%`)}
// headers={{
// Authorization: `${token_type} ${access_token}`
// }}
// ...and many others options
/>
</CacheManagerProvider>
)
}
entryExpiresIn
)-1
(default) - the cache is forever0
- the cache is automatically reset on the next render{seconds}
- reset the cache after a certain number of seconds, after loading the file (when updating the render)See the contributing guide to learn how to contribute to the repository and the development workflow.
MIT
Generated using TypeDoc