Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
2.7k views
in Technique[技术] by (71.8m points)

React Native WebView is not getting loaded same url request second times

I am using react-native-webview in my project and i facing issue while loading the request second times.

Here is the request object

type WebRequest = {
  uri: string,
  method: string,
  body?: any,
  headers: any
}

below is the state

const [webRequest, setWebRequest] = useState<WebRequest>();

this is how i implemented web view

<WebView
        ref={WEBVIEW_REF => (WebViewRef = WEBVIEW_REF)}
        source={webRequest}
        onLoadStart={(e) => {
          console.log("onLoadStart ", e);
        }}
        onLoadEnd={(e) => {
          console.log("onLoadEnd ", e);
        }}
        onError={(e) => {
     console.log("onLoadEnd ", e);
       }}
      />

On click on a button the below code will be executed and will be loaded url request.

const webViewRequest: WebRequest = {
      uri: "http://example.com/page”,
      method: 'GET',
      headers: {
        “header1: “aaaaa”,
        "header2”: “xxx”
      },
    }
    setWebRequest(webViewRequest)

It is working fine if i click on a button and load the above request but second time webview is not getting loaded.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...