JamTheCode
JamTheCode

Reputation: 41

Status-bar / SafeArea issue with Expo React Native

I was using SafeAreaView for my screens and it behaved normally:

Then I added expo-router for my navigation:

The problem is both on IOS and Android. I want to underline this fact, it is both on IOS and Android.

PLEASE HELP, been struggling for a while now

Upvotes: 4

Views: 3736

Answers (2)

Rashon
Rashon

Reputation: 75

Old post, but commenting my solution was same as above, set my _layout.js to this below:

import { StyleSheet } from "react-native";
import { Stack } from "expo-router";
import { SafeAreaProvider } from "react-native-safe-area-context";

export default function RootLayout() {
  return (
    <SafeAreaProvider style={styles.container}>
      <Stack screenOptions={{ headerShown: false }}>
        <Stack.Screen name="index" />
      </Stack>
    </SafeAreaProvider>
  );
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    backgroundColor: "#171717",
  },
});

Upvotes: 0

Yanderson Kaio
Yanderson Kaio

Reputation: 31

I had the same issue here. I solved it by setting the header as null in the screenOptions of my root layout file (_layout) instead of setting headerShown as false.

Before, it was like this: <Stack screenOptions={{ headerShown: false }} /> and had double padding. Now, it is like this: <Stack screenOptions={{ header: () => null }} /> and the additional padding is gone.

My root layout file

import { Stack } from "expo-router";
import { StyleSheet } from "react-native";
import { SafeAreaView } from "react-native-safe-area-context";

export default function RootLayout() {
    return (
        <SafeAreaView style={styles.container}>
            <Stack screenOptions={{ header: () => null }} />
        </SafeAreaView>

    );
}

const styles = StyleSheet.create({
    container: {
        flex: 1
    }
})

My root index file

import { Redirect } from 'expo-router';

export default function Page() {
    return <Redirect href={"/(drawer)/home"} />;
} 

Upvotes: 3

Related Questions