Search code examples
javascriptreactjsreact-nativetvosapple-tv

React-native: How to implement caching for image in tvOS?


React-native: How to implement caching for image in tvOS ?

I want to implement caching for image that I download on internet, how to do that with apple tv ? I have tried many library, but anyone are compatible with the apple tv


Solution

  • React Native FS is now compatible with tvOS see. So now you can use any library that use it !

    For exemple with react-native-cacheable-image :

    You need to install and link react-native-fs, just type:

    npm install react-native-fs --save # install react-native-fs
    react-native link react-native-fs #link native module
    

    Now you can install react-native-cacheable-image:

    npm i react-native-cacheable-image --save
    

    Import this library like this:

    import CacheableImage from 'react-native-cacheable-image'
    

    And now you can create an image like this with JSX:

     <CacheableImage
                style={{height:20}}
                source={{uri: "http://www.foobar.com/defaultImage.jpeg"}}
            >
    

    There some specification in terms of your device just see the documentation of react-native-cacheable-image

    I hope my answer was helpful