Я пытаюсь загрузить функцию imagePicker () каждый раз, когда выбирается определенная вкладка.Прямо сейчас я пытаюсь захватить TabFocus, но это не работает.Есть ли другой способ, которым я могу достичь этого?
export class AddImage extends Component{
imagePicker(){
//definition of function.......
}
static navigationOptions = ({navigation}) => {
return {
tabBarOnPress({jumpToIndex, scene}) {
navigation.state.params.onTabFocus();
}
}
}
componentDidMount(){
this.props.navigation.setParams({onTabFocus: this.imagePicker.bind(this)})
}
}
export default createBottomTabNavigator({
Home: { screen: Home,
navigationOptions:{
tabBarLabel: 'Home',
tabBarIcon: ({tintColor})=>(<Icon name="home" color={tintColor} size={24}/>)
}
},
AddImage: { screen: AddImage
navigationOptions:{
tabBarLabel: '',
tabBarIcon: ({tintColor})=>(<Icon name="plus-square" color={tintColor} size={24}/>),
tabBarOnPress: ({navigation})=> {navigaition.state.params.onTabFocus() },
}
},
Settings: { screen: Settings,
navigationOptions:{
tabBarLabel: 'Settings',
tabBarIcon: ({tintColor})=>(<Icon name="cog" color={tintColor} size={24}/>)
}
},
},
{//other bottom tab configurations
order: ['Home', 'AddImage', 'Settings'],
}
});