Skip to content

[WebView] WebView types missing #13662

Closed
Closed
@Kingles

Description

@Kingles

Description

WebView has no proper flowtypes.

Reproduction Steps and Sample Code

Environment

  • react-native: 0.43.4
  • flow-bin: 0.40.0
  1. import WebView
  2. use it
  3. attempt to access props or exposed functions
  4. 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions