import WebViewComponent from 'react-native-webview'; import React, { Component } from 'react'; import { ActivityIndicator, View, StyleSheet } from 'react-native'; import ScriptManager from './scripts'; import { GetScriptOptions } from './scripts'; interface Props { [key: string]: any; onRef?(ref: any): void; source: any; scriptOptions: GetScriptOptions; scriptLoading?: { style?: any; color?: string; } } export default class Webview extends Component { state = { injectedJavaScript: '', } componentDidMount() { this.getScripts(); } getScripts = async () => { const scripts = await ScriptManager.getScripts(this.props.scriptOptions); this.setState({ injectedJavaScript: ScriptManager.combineScripts(scripts), }); } render() { if (!this.state.injectedJavaScript && this.props.scriptLoading) { return ( ); }; return ( ); } } const styles = StyleSheet.create({ loadingContainer: { flex: 1, justifyContent: 'center', alignItems: 'center', } });