Search code examples
react-nativeexpooffline-caching

React Native expo load an image when device is offline


I am trying to load an image when the device is offline. Basically it's an offline notice like bellow image, so the image will only show when the device is offline. I have already referred to expo offline docs https://docs.expo.io/guides/offline-support/ but it's not working I think I am missing something please help me. Show me an example of how to do it.

enter image description here


Solution

  • 1) the image will be available locally in standalone apps if you use assetBundlePatterns, which is enabled by default. see: https://docs.expo.io/guides/preloading-and-caching-assets/#bundling-assets

    2) in expo client, if you want it to be available when offline you can cache the image. see: https://docs.expo.io/guides/preloading-and-caching-assets/#pre-loading-and-caching-assets