我在使用从https://reactnavigation.org/docs/navigators/tab的React Navigation的Tab Navigator,当我在Tab.screen之间切换时,我没有在this.props.navigation中获得任何导航状态。如何获取当前的导航状态
标签导航:
import React, { Component } from 'react';
import { View, Text, Image} from 'react-native';
import DashboardTabScreen from 'FinanceBakerZ/src/components/dashboard/DashboardTabScreen';
import { TabNavigator } from 'react-navigation';
render() {
console.log(this.props.navigation);
return (
<View>
<DashboardTabNavigator />
</View>
);
}
const DashboardTabNavigator = TabNavigator({
TODAY: {
screen: DashboardTabScreen
},
THISWEEK: {
screen: DashboardTabScreen
}
});
仪表板操作:
import React, { Component } from 'react';
import { View, Text} from 'react-native';
export default class DashboardTabScreen extends Component {
constructor(props) {
super(props);
this.state = {};
console.log('props', props);
}
render() {
console.log('props', this.props);
return (
<View style={{flex: 1}}>
<Text>Checking!</Text>
</View>
);
}
}
我会在仪表盘屏幕的道具时,它呈现组件第一,但是当我切换我没有得到道具标签。 我需要获取当前的屏幕名称,例如TODAY或THISWEEK。