【发布时间】:2020-10-04 05:25:48
【问题描述】:
https://reactnavigation.org/docs/headers#replacing-the-title-with-a-custom-component
在此链接中,有一个示例代码(复制如下)。在 options prop 中,headerTitle 是一个接受 props 作为参数的函数。我们在哪里传递该道具,因为我们从未真正调用 headerTitle。是否有一些默认的道具被传递,我们正在将其重命名为道具?
function LogoTitle() {
return (
<Image
style={{ width: 50, height: 50 }}
source={require('@expo/snack-static/react-native-logo.png')}
/>
);
}
function StackScreen() {
return (
<Stack.Navigator>
<Stack.Screen
name="Home"
component={HomeScreen}
options={{ headerTitle: props => <LogoTitle {...props} /> }}
/>
</Stack.Navigator>
);
}
【问题讨论】:
标签: react-native react-navigation