【发布时间】:2020-06-20 13:23:54
【问题描述】:
我试图将每个页面的标题从反应导航传递到标题组件,但没有运气。我很确定我正在正确发送道具,但我不知道如何使用我尝试使用 {props.headerTitle} 但没有运气。
标题组件:
export default function Header() {
return (
<View style={styles.header}>
<Text>{props.headerTitle}</Text>
</View>
);
}
导航
<AuthStack.Navigator initialRouteName={RegisterLogin}>
<AuthStack.Screen
name="RegisterLogin"
component={RegisterLogin}
options={({navigation, route}) => ({
headerShown: false,
headerTitle: (props) => <Header {...props} />,
headerStyle: {
backgroundColor: 'red',
elevation: 0,
shadowOpacity: 0,
borderBottomWidth: 0,
},
})}
/>
<AuthStack.Screen
name="Login"
component={LoginWithContext}
options={({navigation, route}) => ({
headerTitle: (props) => <Header {...props} />,
headerStyle: {
backgroundColor: 'red',
elevation: 0,
shadowOpacity: 0,
borderBottomWidth: 0,
},
})}
/>
【问题讨论】:
标签: javascript reactjs react-native