React Native WebView rendering an unexpected border below

This is a little hard to describe. I am using the native component WebViewto create a mini browser. It works fine, but there is a strange black frame at the bottom that I did not insert. It appears when scrolling to the bottom of the web page or beyond.

You can see a thin black line above the text "blah" below. The reason for the blah text and the pink section below was the exception to the wandering style borderBottom*in WebView or its container.

Another thing to note is that when a page is refreshed briefly, it disappears briefly, so it looks like a WebView HTML. But I don’t understand how and why, because a) it appears on all sites and b) it does not appear in other iOS browsers.

Am I doing something weird here?

Screenshot: enter image description here

Elements and styles:

<View style={styles.container as any}>
    <View style={styles.header as any}>
      {this.addressbarButtonProps().map(props => React.createElement(Button, { ...props, key: props.title }))}
      <TextInput
        ref={ADDRESSBAR_REF}
        placeholder="type url"
        style={{ minWidth: this.screenWidth - 50 * this.addressbarButtonProps().filter(b => !b.hidden).length - 10 }}
        />
    </View>
    <WebView
      ref={WEBVIEW_REF}
      source={{uri: this.state.uri}}
      style={{ ...styles.web, width: this.screenWidth, paddingBottom: 0, padding: 0 }}
      scalesPageToFit={true}
      allowsInlineMediaPlayback={true}
      onMessage={m => this.onMessage(m.nativeEvent.data)}
      injectedJavaScript={js}
      startInLoadingState={true}
    />
    <Text style={{ borderTopWidth:20, borderTopColor: "red" }}>blah</Text>
  </View>

const styles = {
  container: {
    paddingTop: 20,
    flex: 1,
    alignItems: "center",
    justifyContent: "space-between",
    backgroundColor: "#fafafa",
    borderBottomColor: "pink",
    borderBottomWidth: 100
  },
  header: {
    flexDirection: "row",
    alignItems: "flex-start",
    justifyContent: "flex-start",
    alignSelf: "stretch"
  },
  web: {
    flex: 1,
    borderBottomColor: "#fafafa",
    backgroundColor: "#fafafa"
  }
}
+4
source share
1 answer

Set backgroundColor WebView to transparent and the border will not be displayed.

<Webview style={{backgroundColor: 'transparent'}} .../>
+13
source

Source: https://habr.com/ru/post/1663975/


All Articles