question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Offline webview(cache) support

See original GitHub issue

Is there anyway to show the cached version when there is no internet? At the moment it shows only an error that there is no internet.

      <WebView
        cacheMode="LOAD_CACHE_ELSE_NETWORK"
        cacheEnabled
        sharedCookiesEnabled={true}
        startInLoadingState
        onError={() => console.warn("error")}
        source={{
                uri: "http://google.nl",
              }
        }
      />

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:7
  • Comments:9

github_iconTop GitHub Comments

1reaction
Nico-T-Ihlecommented, Jul 13, 2022

Hey if you want to show your own custom error srceen try this:

  1. First install react-native-community/netinfo
  2. dont forget if your on mac go to your /ios and do pod install
  3. Then import {useNetInfo} from “@react-native-community/netinfo”; in your Project

if you did this remove your return and use this instead for reandering your content

if(netInfo.isConnected != false) { console.log("y wifi") console.log("y wifi") return ( <WebView source={ YOUR URL } ) } else if(netInfo.isConnected != true) { console.log("n wifi"); return( <WebView source={ YOUR CUSTOM HTML } scalesPageToFit={true} /> ) }

notice you can use HTML In webview https://reactnative.dev/docs/0.63/webview

you just check if you have a connection if yes then show your site and if you no connectio then your your custom html site .

hope i could help somebody

1reaction
ajaxsyscommented, Oct 23, 2021

I think we can open a local default web page ( cached local ) when offline, instead page like this: 807D83ABB86CE99075E1F3B9B4D2498C

Read more comments on GitHub >

github_iconTop Results From Across the Web

Loading Cache when Offline in Android Webview
I have an application which loads urls from a website. Now I want the application to use the cache when offline ...
Read more >
Is WKWebView Support HTML5 Offline Application Cache
HTML5 Offline Application Cache Is supported on Safari but is it supported in WKWebView? I found some links in StackOverflow but i am...
Read more >
Offline webview(cache) support · Issue #1387 · react-native ...
Is there anyway to show the cached version when there is no internet? At the moment it shows only an error that there...
Read more >
react-native-offline-cache-webview - npm
Start using react-native-offline-cache-webview in your project by running `npm i react-native-offline-cache-webview`.
Read more >
react-native-offline-cache-webview - npm package - Snyk
CacheWebView is a custom implement of Android WebView resource interceptor. It beyond system WebView cache space limit, let cache config more simple ,fast...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found