Closed
Description
Description
WebView has no proper flowtypes.
Reproduction Steps and Sample Code
Environment
react-native
: 0.43.4flow-bin
: 0.40.0
- import WebView
- use it
- attempt to access props or exposed functions
- observe that props and exposed methods (
injectJavaScript
, for example) are not covered by flow.
// @flow
import React, {PureComponent} from 'react';
import {WebView, View, Button} from 'react-native';
import htmlTemplate from './template.html';
export default class TestComponent extends PureComponent {
webview: ?WebView = null;
handlePress = () => {
const {webview} = this;
if (webview) {
const script = "alert('sup :3')";
webview.injectJavaScript(script);
}
};
render() {
<View>
<Button onPress={this.handlePress}>
Press me!
</Button>
<WebView
ref={(webview: WebView) => {
this.webview = webview;
}}
source={htmlTemplate}
/>
</View>;
}
}
Solution
Add missing flowtypes to WebView.
Additional Information
- React Native version:
0.43.4
- Platform: both
- Development Operating System: MacOS
- Dev tools: N/A