react-native - react 导航 : Apply SafeAreaView globally with Redux

标签 react-native redux react-navigation iphone-x

我正在尝试以全局方式将 SafeAreaView 应用到我的应用程序,以避免将它单独插入到每个 View 中,但是当我这样做时, View 的顶部和底部会出现一个阴影,并且我意识到那是因为我应用了 index.js 中的 SafeAreaView 但是当我直接在每个 View 中执行时,它按预期工作,你知道为什么或者我做错了什么吗?

在 index.js 中使用 SafeAreaView

const styles = StyleSheet.create({
  safeArea: {
    flex: 1,
    backgroundColor: 'white',
    shadowColor: 'transparent',
  },
});

const AppContainer = () => (
  <Provider store={store}>
    <SafeAreaView style={styles.safeArea}>
      <StatusBar backgroundColor="#EEEEEE" barStyle="dark-content" />
      <AppWithNavigationState />
    </SafeAreaView>
  </Provider>
);

enter image description here

在特定 View 中使用 SafeAreaView

enter image description here

我试图移除那个阴影,但不可能。

最佳答案

您需要将 shadowColor: 'transparent' 添加到 stackNavigatorcardStyle 中,无论您在 routeConfig 中使用它

像这样

cardStyle: {
    shadowColor: 'transparent'
  }

关于react-native - react 导航 : Apply SafeAreaView globally with Redux,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49306334/

相关文章:

javascript - 嵌套文本,垂直对齐不起作用 - React Native

java - Android:错误:找不到符号包。add(new MyAppPackage())

javascript - Redux Form v6 - 调用 onSubmit 函数,但不调度操作

reactjs - 如何使用 this.props.change 更改 redux 形式的深层字段

javascript - redux-persist:persist 和 rehydrate 有什么区别?

TypeScript 的 import() typeof json

reactjs - 如何在 React Redux 中创建临时状态?

android - React native 状态栏不适用于 android 中的 react-navigation

javascript - 如何在使用 React-Navigation 和 Expo 的同时实现一次字体?

reactjs - 类型错误 : undefined is not an object (evaluating 'route.params' )