This commit is contained in:
Philip Cesar Garay
2025-07-31 21:25:33 +08:00
parent 5cfbc81e3a
commit 84fc719a10
307 changed files with 46470 additions and 0 deletions
+3
View File
@@ -0,0 +1,3 @@
import { WebView as NativeWebView } from "react-native-webview";
export const WebView = NativeWebView;
+39
View File
@@ -0,0 +1,39 @@
import React, { useEffect, useRef } from "react";
export const WebView = ({ source, allowFullScreen, onURLChange }) => {
const iframeRef = useRef(null);
useEffect(() => {
// Définition de la fonction handleLoad à l'intérieur du useEffect
const handleLoad = () => {
try {
const currentUrl = iframeRef.current?.contentWindow?.location?.href;
onURLChange(currentUrl); // Appeler la fonction de callback avec l'URL actuelle
} catch (error) {
console.error("Erreur d'accès à l'URL de l'iframe:", error);
}
};
const iframeElement = iframeRef.current;
iframeElement.addEventListener("load", handleLoad);
return () => {
iframeElement.removeEventListener("load", handleLoad);
};
}, [onURLChange]); // Assurez-vous que cette dépendance est correctement définie pour éviter des appels excessifs
return (
<iframe
ref={iframeRef}
src={source?.uri}
style={{
display: "flex",
border: "none",
width: "100%",
height: "100vh",
}}
title="minuit.starter"
allowFullScreen={allowFullScreen}
/>
);
};