React Native Webview displays blank page while loading any document using Google Doc Viewer

Viewed 251

Here is the code I am using as suggested for loading pdf, ppt, doc, txt in react-native-webview using google doc viewer URL. But for few times(3-4 times) it just does not load any content and also without any error and after few attempts it loads the page. I don't know what's the issue. I have tried all the suggestions found uptil now on google but didn't come to a stable and proper solution.

let webViewTxt = `http://docs.google.com/viewer?url=${url}`;
     <Modal
        isVisible={visibleModalPreview === 'center'}
        onSwipeComplete={() => [
          setVisibilityModalPreview(null),
          setPreviewPath('')
        ]}
        onRequestClose={() => [
          setVisibilityModalPreview(null),
          setPreviewPath('')
        ]}
        style={{
          width: '100%',
          height: '60%',
          alignSelf: 'center'
        }}>

       <WebView
          style={{
            backgroundColor: colors.transparent
          }}
          source={{uri: }}
          originWhitelist={['*']}
          useWebKit
          allowUniversalAccessFromFileURLs
          allowsInlineMediaPlayback="true"
          allowFileAccess={true}
          allowFileAccessFromFileURLs={true}
          startInLoadingState={true}
          scalesPageToFit={true}
          javaScriptEnabled={true}
          domStorageEnabled={true}
       />
     </Modal>

Please let me know what should be done if anybody has any answer or any other alternative to display the documents from URL within the app without using any external application. Really stuck on this since days!

0 Answers
Related