每次我尝试在stacknavigation中设置自定义标头时,都会出现错误:“无法找到变量View”。当我只用文本替换组件时,它就起作用了。
每次我为headerTitel使用“ LogoTitle”类时都会出现错误
试图使用一个类的常量,但是剂量起作用了
const TabNavigation = createMaterialTopTabNavigator({
AllChats: { screen: AllChatsScreen,
navigationOptions: {
tabBarLabel: "Chats",}}});
class LogoTitle extends React.Component {
render() {
return (
<Image
source={require('./spiro.jpg')}
style={{ width: 30, height: 30 }}/>);}}
const SignedInn = createStackNavigator({
TabNavigation: {
screen: TabNavigation,
},},{
navigationOptions: {
headerTitle: <LogoTitle/>}})
export const createRootNavigator = (signedIn = false) => {
return createSwitchNavigator(
{
SignedIn: {
screen: SignedInn}});};
答案 0 :(得分:0)
您需要使用header而不是headerTitle才能使用View
const SignedIn = createStackNavigator ({
TabNavigation:{screen: TabNavigation,
navigationOptions: ({navigation}) => ({
header: <LogoTitle navigation= {navigation} />,
})
},
})