React native web view not load uri second time for a while

I'm trying to add web view for some payment functions on react native. When ı add it like this it works for 1 time then it gives me error like in picture or says too many http request on ios. I already search and try many solution about this like change style, give some props etc but still not fixed it exactly. Anyone know how can ı fix it? Here is example code

import React, { useState, useEffect, useRef } from "react";
import { SafeAreaView, Button, View } from "@components";
import { connect } from "react-redux";
import styles from "./styles";
import { WebView } from "react-native-webview";

const Payment = ({ navigation, route }) => {
  const onSubmit = async () => {
    //get values and url from backend and set it
    setWebViewUrl(paymenturl);
    setShowWebView(true);
  };

  const [showWebView, setShowWebView] = useState(false);
  const [webViewUrl, setWebViewUrl] = useState(null);

  const webRef = useRef(null);
  const MyWebComponent = ({ url }) => {
    return (
      <WebView
        style=
        startInLoadingState={true}
        ref={webRef}
        source=
        onNavigationStateChange={async (e) => {
          //doing someting for payment
        }}
      />
    );
  };

  return (
    <View style=>
      {showWebView && <MyWebComponent url={webViewUrl} />}
      {!showWebView && (
        <SafeAreaView style={styles.mainContainer}>
          {/* input for card info */}
          <Button onPress={onSubmit}>Payment</Button>
        </SafeAreaView>
      )}
    </View>
  );
};

const mapStateToProps = (state) => ({});

const mapDispatchToProps = {};

export default connect(mapStateToProps, mapDispatchToProps)(Payment);

Note:sometimes i wait for a while and it gets fixed as it is. Sometimes I do ctrl + s and it fix for one time. I don't understand why he did this. It also affects my web view on completely different pages. I wonder if there should be a way to close or delete the webview so that when I make the same request again, it will load from scratch. And here is the error result. enter image description here



Comments

Popular posts from this blog

Today Walkin 14th-Sept

Network Error and Timeout on Authorize.net JS

Spring Elasticsearch Operations