react-native-safe-area-context不工作?

kjthegm6  于 2023-04-12  发布在  React
关注(0)|答案(1)|浏览(170)

我正在使用Android模拟器,SafeAreaProvider不工作(即,转到屏幕顶部太远)

import { StatusBar } from "expo-status-bar";
import { NavigationContainer } from "@react-navigation/native";
import RootNavigator from "./navigator/RootNavigator";
import { Provider } from "react-redux";
import { store } from "./redux/store";
import { SafeAreaProvider } from "react-native-safe-area-context";

export default function App() {
  return (
    <SafeAreaProvider>
      <NavigationContainer>
        <StatusBar style="auto" />
        <Provider store={store}>
          <RootNavigator />
        </Provider>
      </NavigationContainer>
    </SafeAreaProvider>
  );
}
hmmo2u0o

hmmo2u0o1#

你需要用SafeAreaView Package 你的应用程序才能使它工作。从同一个库导入它,并将你的代码更新为:

<SafeAreaProvider>
 <SafeAreaView>
  <NavigationContainer>
   <StatusBar style="auto" />
    <Provider store={store}>
     <RootNavigator />
    </Provider>
  </NavigationContainer>
 </SafeAreaView>
</SafeAreaProvider>

相关问题