react-native-safe-area-context: [Android] SafeAreView is not working on Android with notch, tested on Pixel 7 emulator

Hey, I’ve noticed that the SafeAreaView is not working on the Pixel 7 emulator. Any ideas on how it might be fixed? 😃

Here’s a screenshot:

Screenshot 2023-11-15 at 18 42 22

Code:

import React from 'react'
import { SafeAreaProvider, SafeAreaView, useSafeAreaInsets } from 'react-native-safe-area-context'
import { Text, View } from 'react-native'

const TestComponent = () => {
    const insets = useSafeAreaInsets()

    console.log('insets', insets)   // LOG  insets {"bottom": 0, "left": 0, "right": 0, "top": 0}
    
    return (
        <SafeAreaView>
            <View>
                <Text>Here Android notch Pixel 7 Here Android notch Pixel 7 Here Android notch Pixel 7</Text>
            </View>
        </SafeAreaView>
    )
}

export const App = (): JSX.Element => {
    return (
        <SafeAreaProvider>
            <TestComponent />
        </SafeAreaProvider>
    )
}

About this issue

  • Original URL
  • State: open
  • Created 3 years ago
  • Reactions: 23
  • Comments: 26 (3 by maintainers)

Most upvoted comments

The fix for me was to

import { SafeAreaView } from 'react-native-safe-area-context'; Used version ^5.2.0 instead of import { SafeAreaView } from 'react-native';

I think I’m running into the same issue, specifically on Android 35: the bottom safe area inset is zero when it shouldn’t be, causing content to be clipped off the bottom of the screen.

currently have the same issue, been throwing every resource at it, even asked AI to generate 3 different simple code to wrap around this emulator and it does not work