【问题标题】:Component not rendering in headerTitle组件未在 headerTitle 中呈现
【发布时间】:2021-09-14 12:49:09
【问题描述】:

我的 HomeHeader 组件未在 headerTitle 中呈现。我期待渲染,因为当我将其作为直接字符串执行时,它会显示在 headerTitle 中。

const HomeHeader = (props) => {
  return (
    <View>
    <Text>Home</Text>
    </View>
  )
}

function RootNavigator() {
  return (
    <Stack.Navigator>
      <Stack.Screen name="Home" component={HomeScreen} options={{headerTitle: HomeHeader}} />
      <Stack.Screen name="ChatRoom" component={ChatRoomScreen} options={{ headerShown: true }} />
    
      

      <Stack.Screen name="NotFound" component={NotFoundScreen} options={{ title: 'Oops!' }} />
      <Stack.Group screenOptions={{ presentation: 'modal' }}>
        <Stack.Screen name="Modal" component={ModalScreen} />
      </Stack.Group>
    </Stack.Navigator>
  );
}

我有什么遗漏吗?请在顶部查看 HomeHeader 组件,然后它当前位于我的主屏幕的 headerTitle 内。

【问题讨论】:

  • 如果你只向 headerTitle 传递一个字符串,比如 headerTitle: 'Home' ,它会显示吗?

标签: react-native expo


【解决方案1】:

我会为视图添加一些大小,并为文本添加一些样式...

【讨论】:

    猜你喜欢
    • 2014-08-12
    • 2017-10-14
    • 2017-10-29
    • 2013-06-08
    • 2018-05-30
    • 2021-11-19
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多