我想在无状态屏幕中自定义标题。但是,没有任何显示。我有一个route.js文件,可为所有屏幕创建一个堆栈导航器。我可以将我的navigationOptions添加到route.js文件中,但我想在每个屏幕上动态地进行操作。
export default UserScreen = ({navigation}) => {
useEffect(() => {
navigation.setParams({
headerLeft: (
<Icon
name="edit"
style={{marginLeft: 5}}
size={26}
color="white"
onPress={() => navigation.toggleDrawer()}
/>
),
headerRight: (
<Icon
name="edit"
style={{marginRight: 5}}
size={26}
color="white"
onPress={() =>
navigation.navigate('DailyScreen', {jwt: 'token', userId: '3'})
}
/>
),
title: `Dynamic Title`,
headerBackTitle: null,
headerStyle: {
backgroundColor: '#00B386',
},
headerTitleStyle: {
color: 'white',
fontSize: 21,
},
});
}, []);
现在我得到: no custom header