feat: fixes and formatter
This commit is contained in:
@@ -1,3 +1,3 @@
|
||||
import { WebView as NativeWebView } from "react-native-webview";
|
||||
import { WebView as NativeWebView } from 'react-native-webview'
|
||||
|
||||
export const WebView = NativeWebView;
|
||||
export const WebView = NativeWebView
|
||||
|
||||
@@ -1,39 +1,39 @@
|
||||
import React, { useEffect, useRef } from "react";
|
||||
import React, { useEffect, useRef } from 'react'
|
||||
|
||||
export const WebView = ({ source, allowFullScreen, onURLChange }) => {
|
||||
const iframeRef = useRef(null);
|
||||
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
|
||||
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);
|
||||
console.error("Erreur d'accès à l'URL de l'iframe:", error)
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
const iframeElement = iframeRef.current;
|
||||
iframeElement.addEventListener("load", handleLoad);
|
||||
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
|
||||
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",
|
||||
display: 'flex',
|
||||
border: 'none',
|
||||
width: '100%',
|
||||
height: '100vh',
|
||||
}}
|
||||
title="minuit.starter"
|
||||
allowFullScreen={allowFullScreen}
|
||||
/>
|
||||
);
|
||||
};
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user