В моем случае я создаю свой собственный заголовочный компонент и использую его на каждой странице, которую я хочу. это позволило мне настроить заголовок для каждой страницы.
Абсолютно это черный ход, и я надеюсь, что другие люди точно ответят на ваш вопрос.
Это пример ...
Домашняя страница:
export default class Home extends Component {
render() {
return (
<View style={{ flex: 1 }}>
<Header showBorder={true}/>
<ScrollView>
...
</ScrollView>
</View>
);
}
}
Компонент заголовка:
export default class Header extends React.PureComponent {
renderTitle = () => {
if (this.props.title) {
return (
<View style={{ flexDirection: 'column', flex: 3, justifyContent: 'center' }}>
<View style={{ alignSelf: 'flex-start' }}>
<Text style={[styles.fontBold, { fontSize:17, color: colors.borderWidthColor }]}>{this.props.title}</Text>
</View>
</View>
)
}
}
renderBack = () => {
if (this.props.back) {
return (
<View style={{ marginTop:3 }}>
<TouchableOpacity
onPress={() => {
this.props.navigation.goBack()
}}
style={{ alignSelf: 'flex-start' }}>
<Icon name="md-arrow-back" size={23} color="black" />
</TouchableOpacity>
</View>
)
}
}
render() {
return (
<View style={[{ height: 70, backgroundColor: this.props.backgroundColor, width: win.width, borderBottomWidth: this.props.showBorder ? 1 : 0 }]}>
<View style={{ flex: 1, flexDirection: 'row', marginTop: Platform.OS == 'ios' ? 17 : 3 }}>
<View style={{ flexDirection: 'column', flex: 1, justifyContent: 'center', marginLeft: 12 }}>
{this.renderBack()}
{this.renderTitle()}
</View>
</View>
</View>
)
}
}