Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Android] White blank screen when load file in a webview #21939

Closed
3 tasks done
MrSeaWave opened this issue Oct 25, 2018 · 8 comments
Closed
3 tasks done

[Android] White blank screen when load file in a webview #21939

MrSeaWave opened this issue Oct 25, 2018 · 8 comments
Labels
Component: WebView Related to the WebView component. Platform: Android Android applications. Resolution: Locked This issue was locked by the bot.

Comments

@MrSeaWave
Copy link

MrSeaWave commented Oct 25, 2018

Environment

react-native info

React Native Environment Info:
    System:
      OS: macOS 10.14
      CPU: x64 Intel(R) Core(TM) i5-7400 CPU @ 3.00GHz
      Memory: 30.62 MB / 16.00 GB
      Shell: 5.3 - /bin/zsh
    Binaries:
      Node: 8.12.0 - /usr/local/bin/node
      Yarn: 1.10.1 - /usr/local/bin/yarn
      npm: 6.4.1 - /usr/local/bin/npm
      Watchman: 4.9.0 - /usr/local/bin/watchman
    SDKs:
      iOS SDK:
        Platforms: iOS 12.0, macOS 10.14, tvOS 12.0, watchOS 5.0
      Android SDK:
        Build Tools: 26.0.3, 27.0.3, 28.0.3
        API Levels: 26, 27, 28
    IDEs:
      Android Studio: 3.2 AI-181.5540.7.32.5056338
      Xcode: 10.0/10A255 - /usr/bin/xcodebuild
    npmPackages:
      react: 16.6.0-alpha.8af6728 => 16.6.0-alpha.8af6728 
      react-native: 0.57.3 => 0.57.3 
    npmGlobalPackages:
      react-native-cli: 2.0.1

my package.json

{
  "name": "TemReactNative",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "start": "node node_modules/react-native/local-cli/cli.js start",
    "test": "jest"
  },
  "dependencies": {
    "react": "16.6.0-alpha.8af6728",
    "react-native": "0.57.3"
  },
  "devDependencies": {
    "babel-jest": "23.6.0",
    "jest": "23.6.0",
    "metro-react-native-babel-preset": "0.48.1",
    "react-test-renderer": "16.6.0-alpha.8af6728"
  },
  "jest": {
    "preset": "react-native"
  }
}

Description

「Android」White blank screen when load file in a webview

2018-10-25 11 58 34

Reproducible Demo

you can repeat it with the code

react-native init AwesomeProject
cd AwesomeProject
react-native run-android

&& my code

import React, { Component } from 'react'
import { View, Text, TouchableOpacity, WebView } from 'react-native'

class TestWebView extends Component {
  constructor(props) {
    super(props)
    this.state = { visible: false }
  }
  onChange = () => {
    this.setState(preState => ({ visible: !preState.visible }))
  }

  render() {
    const { visible } = this.state
    return (
      <View
        style={{
          flex: 1,
          justifyContent: 'center',
          alignItems: 'center',
          backgroundColor: '#CCCCFF'
        }}
      >
        <TouchableOpacity
          style={{ backgroundColor: '#E3C07B', height: 50, width: 100 }}
          onPress={this.onChange}
        >
          <Text>Show WebView</Text>
        </TouchableOpacity>
        {visible ? (
          <View style={{ height: 150, width: 150 }}>
            <WebView
              source={{ uri: 'https://github.com/facebook/react-native' }}
              scalesPageToFit={true}
            />
          </View>
        ) : null}
      </View>
    )
  }
}

export default TestWebView
@MrSeaWave MrSeaWave changed the title [Androiud] White blank screen when load file in a webview [Android] White blank screen when load file in a webview Oct 25, 2018
@react-native-bot react-native-bot added Platform: Android Android applications. Component: WebView Related to the WebView component. 🔶Components labels Oct 25, 2018
@Titozzz
Copy link
Collaborator

Titozzz commented Oct 25, 2018

Try adding overflow: 'hidden' to your view with 150 150 please

@MrSeaWave
Copy link
Author

oh,yeah,It runs successfully, thanks so much @Titozzz

<View style={{ height: 150, width: 150,overflow:'hidden' }}>
            <WebView
              source={{ uri: 'https://github.com/facebook/react-native' }}
              scalesPageToFit={true}
            />
</View>

2018-10-26 11 16 14

@mtheus
Copy link

mtheus commented Oct 29, 2018

It's related? #21789

@dulmandakh
Copy link
Contributor

Please use https://github.com/react-native-community/react-native-webview and file a bug there if you have issues. Thank you

@nppull
Copy link

nppull commented May 29, 2019

thanks.. fixed for me <3

@KirillTarasenko
Copy link

Try adding overflow: 'hidden' to your view with 150 150 please

you are best!)

@vegin
Copy link

vegin commented Jul 19, 2019

thanks so much @Titozzz

@shuqiong2015
Copy link

shuqiong2015 commented Jul 24, 2019

why overflow: 'hidden' can works?

@facebook facebook locked as resolved and limited conversation to collaborators Oct 30, 2019
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label Oct 30, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Component: WebView Related to the WebView component. Platform: Android Android applications. Resolution: Locked This issue was locked by the bot.
Projects
None yet
Development

No branches or pull requests

9 participants