Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use SafeAreaView with react-native-webview

Tags:

react-native

How can we use SafeAreaView in order to display a WebView? I tried this way :

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

But it's rendering a white page.

Thanks

like image 210
Jats1596 Avatar asked Jun 07 '26 01:06

Jats1596


1 Answers

You didn't specify the height and width of SafeAreaView.

Change <SafeAreaView> to <SafeAreaView style={{ flex:1 }}>

Official documentation clearly says:

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.

like image 161
Vignesh V Pai Avatar answered Jun 10 '26 19:06

Vignesh V Pai