undefined不是一个对象(评估this.props.navigation)

我试图在导航栏右上角保持可触摸不透明度,对于onPress的可触摸不透明度。我想把用户带到主页。undefined不是一个对象(评估this.props.navigation)

constructor(props) { 

super(props);

this.state = {

stAccntList: [],

stUserAccountNo: '',

stCustNo: '',

resp: '',

};

}

static navigationOptions = {

// title: 'myacc',

title: 'My Accounts',

headerRight: <TouchableHighlight onPress={() => {

this.props.navigation.navigate('home');

}}>

<Image style={{ marginRight: 20 }} source={require('../../../resources/toolbar/home_inactive.png')} />

</TouchableHighlight>,

headerTintColor: 'white',

headerStyle: {

backgroundColor: colors.themeColor,

// top: 30

}

}

这是抛出红色屏幕上面的错误。请让我知道我要去哪里错了。

回答:

试试这个是工作:)

  static navigationOptions = ({navigation}) => ({ 

title: 'My Accounts',

headerRight: <TouchableHighlight onPress={() => {

navigation.navigate('home');

}}>

<Image style={{ marginRight: 20, height: 30, width: 30 }}

source={{ uri:https://media.freepik.com/accounts/img/badges/downloads_gold.png'

}} />

</TouchableHighlight>,

headerTintColor: 'white',

headerStyle: {

backgroundColor: colors.themeColor,

// top: 30

}

})

以上是 undefined不是一个对象(评估this.props.navigation) 的全部内容, 来源链接: utcz.com/qa/261247.html

回到顶部