react-native - 将 SafeAreaView 与 react-native-webview 一起使用

标签 react-native

我们如何使用 SafeAreaView为了显示 WebView ?我试过这种方式:

import React from 'react';
import {SafeAreaView, StatusBar} from 'react-native';
import {WebView} from 'react-native-webview';

class ChaineYT extends React.Component {

  render() {
    return (
      <SafeAreaView>
        <WebView
          source={{uri: "someURL"}}
        />
      </SafeAreaView>
    )
  }
}

export default ChaineYT


但它正在呈现一个白页。

谢谢

最佳答案

您没有指定 SafeAreaView 的高度和宽度。

更改 <SafeAreaView><SafeAreaView style={{ flex:1 }}>
官方documentation明确地说:

A component can only expand to fill available space if its parent has dimensions greater than 0. If a parent does not have either a fixed width and height or flex, the parent will have dimensions of 0 and the flex children will not be visible.

关于react-native - 将 SafeAreaView 与 react-native-webview 一起使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58589398/

相关文章:

javascript - 在子更改事件 Firebase 上更新 react native ListView

react-native - 将图像存储在 Android 和 iOS 的原生 react 中?

ios - 模块名称前缀应该已被 native 端剥离,但不适用于 RCTJSCExecutor

javascript - 如何同时使用 stacknavigator 和 tabnavigator?

javascript - java.lang.RuntimeException : Requested enabled DevSupportManager, 但未找到或无法创建 DevSupportManagerImpl 类

javascript - React Native - "undefined is not an object (evaluating ' MyApp.navigation.openDrawer')

javascript - 如何在 native react 中从 firebase firestore 获取除一份以外的所有文档?

react-native - 如何修复 'ReactNative:Cannot run program' 错误

javascript - 带 React Native 导航的可触摸 onPress 不起作用

reactjs - react native : Text wrapping inside View container with fixed-width button