【问题标题】:React Navigation Stack doesn't cover whole screen on desktopReact Navigation Stack 不会覆盖桌面上的整个屏幕
【发布时间】:2020-11-10 10:44:18
【问题描述】:

我正在使用 React Native Web 构建一个简单的 Reddit 克隆。 我在使用 React Navigation 中的 StackNavigator 时遇到了这个问题。

堆栈“屏幕”似乎是根据显示器的尺寸而不是内容来计算的。因此,当当前导航屏幕之前的屏幕高度大于当前屏幕时,内容仍然可见于堆栈屏幕的“后面/下方”。

我的主屏幕:

<View style={{ flex: 1, backgroundColor: colors.background }}>
   <Button style={{ margin: 5 }} action={() => props.navigation.navigate('CreatePost')}><DText>Create post</DText></Button>
   <FlatList
      data={getPosts}
      renderItem={renderPost} 
      keyExtractor={item => item.id}
   />
</View>

我的 createpost 屏幕:

<View style={{ flex: 1, backgroundColor: 'red' }}>
   <View style={styles.element}>
      <TextInput
         placeholder={'Title'}
         onChangeText={setTitle}
         value={getTitle}
      />
      <View style={styles.editor}>
         <SlateEditor setBody={setBody} />
      </View>
      <Button action={() => onCreate(getTitle, getBody)}><DText>Post</DText></Button>
   </View>
</View>

这是一个例子:

我不希望用户能够在 CreatePost 屏幕上滚动。

【问题讨论】:

  • 我刚刚发布了一个新版本的堆栈,应该可以修复它。可以更新一下试试吗?
  • @satya164 在哪里可以找到它?编辑:在官方 github 上找到您的提交 :)
  • 是的,已修复!非常感谢您如此迅速地实施这一点,非常感谢!

标签: react-native react-navigation react-native-web


【解决方案1】:

已通过将 @react-navigation/stack 更新为 5.12.6 来解决此问题。

https://github.com/react-navigation/react-navigation/commit/da35085f1e3440f26eea800c892c88aec64d072f

【讨论】:

    猜你喜欢
    • 2023-04-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-05-09
    • 1970-01-01
    • 2012-06-21
    相关资源
    最近更新 更多