如何将导航从stackNavigator传递到屏幕组件

时间:2020-03-21 13:10:34

标签: javascript reactjs react-native react-navigation react-navigation-v5

我有这个导航树:

var NiceTab1 = createMaterialTopTabNavigator(
    {
        Tab_1: StackNav,
        Tab_2: StackNav,
        Tab_3: StackNav,
        Tab_4: StackNav,
        Tab_5: StackNav,
        Tab_6: StackNav,
        Tab_7: StackNav,
    }
}

StackNav:

var StackNav= createStackNavigator({
  FirstScreen: {
    screen: ()=><MyScreen/>,
    navigationOptions: {
      headerShown: false
    }
  }
}

我的屏幕:

class MyScreen extends Component {
  constructor(props) {
    super(props);
    this.state = {};
  }
  render() {

    return (
      <View style={styles.root}>
        <StatusBar barStyle="light-content" />
        <Text style={styles.title}>{HERE I NEED TO SHOW THE TOP BAR NAVIGATOR ROUTE NAME (navigation.state.routeName)}</Text>
      </View>
    )
  }
}

如果我之间有StackNavigator,如何将顶部栏导航传递到屏幕组件?

谢谢大家

0 个答案:

没有答案