import * as React from 'react' ; import { WebView } from 'react-native-webview' ; import { openUrl , canOpenUrl } from '@frogpond/open-url' ; import type { StyleProp , ViewStyle } from 'react-native' ; type Props = { html : string ; baseUrl ? : string ; style ? : StyleProp < ViewStyle > ; } ; export class HtmlContent extends React . Component < Props > { _webview : WebView ; onNavigationStateChange = ( { url } ) => { if ( ! canOpenUrl ( url ) ) { return ; } if ( url === this . props . baseUrl ) { return ; } this . _webview . stopLoading ( ) ; this . _webview . goBack ( ) ; return openUrl ( url ) ; } ; render ( ) { return ( < WebView ref = { ( ref ) => ( this . _webview = ref ) } onNavigationStateChange = { this . onNavigationStateChange } source = { { html : this . props . html , baseUrl : this . props . baseUrl } } style = { this . props . style } useWebKit = { true } / > ) ; } }