I want to create a wrapper around react-native webview such that I provide some of the default values and client can override them. I would also like to provide default implementations for methods
For Example:
<MyBaseWebView uri ={provided by user of MyBaseWebView}>
MyBaseWebView can have default implementations for onError etc.
I have been using props to send various overrides from client but I am what to do for the following:
ref={this.setRNWebView}
This needs to be only in one of the childreninjectedJavaScript={this.injectedJavaScript()}
I don't want to inject any javascript at all if client does not send it. How can I achieve this?
The BaseWebView class looks like the following:
<WebView
allowsInlineMediaPlayback={this.allowsInlineMediaPlayback()}
ref={this.setRNWebView}
source={{uri: uri}} // from prop
mediaPlaybackRequiresUserAction={this.mediaPlaybackRequiresUserAction()}
onMessage={this.onMessage}
onError={this.onError}
onLoad={this.onLoad}
injectedJavaScript={this.injectedJavaScript()}
/>