React native componentdidmount中的this.props.navigation.setparams未定义

React native componentdidmount中的this.props.navigation.setparams未定义,react-native,react-native-navigation,React Native,React Native Navigation,您好,我正在尝试更改componentDidMount道具中导航选项的头灯 没有定义。我相信我所做的是正确的,它被称为setParams。 这是我的代码: 您好,您使用哪个版本的react导航(如果您正在使用)?您好,您使用哪个版本的react导航(如果您正在使用)? componentDidMount(){ try{ AsyncStorage.getItem('experience').then(experience => { const objExperience = ne

您好,我正在尝试更改componentDidMount道具中导航选项的头灯 没有定义。我相信我所做的是正确的,它被称为setParams。 这是我的代码:


您好,您使用哪个版本的react导航(如果您正在使用)?您好,您使用哪个版本的react导航(如果您正在使用)?
componentDidMount(){
try{
  AsyncStorage.getItem('experience').then(experience => {
    const objExperience = new Experience();
    const newExperience = JSON.parse(experience);

    showExperience = objExperience.showMyLevel((newExperience));

    this.props.navigation.setParams({
      headerTitle: 'Social',
      headerLeft:  <Icon style={{paddingLeft: 20}}
                         name="md-menu" 
                         size={30} 
                         onPress={()=> this.props.navigation.openDrawer()}/>,
      headerRight: <Text style={{paddingRight: 20}}>Level {showExperience}</Text>,
    });
  });
}
catch(e){
  console.log('error from AsyncStorage in' + arguments.callee.name + ': ', e);
}
}
const Social = createStackNavigator({
 SocialScreen:{
   screen: SocialScreen,
   navigationOptions: ({navigation})=>{
     const { params } = navigation.state;

     return params;
   }
 },
 Detail:{
   screen: Detail
 }
});
const DashboardTabNavigator = createBottomTabNavigator({
  Social,
  Work,
  ToDo
},
{
navigationOptions: ({navigation})=>{
  const {routeName} = navigation.state.routes[navigation.state.index];

  return {
    header: null,
    headerTitle: routeName, //it puts the name of the tab on the top of the 
    screen.
  };
}
});