道具不传递到BottomTabNavigator的屏幕

时间:2019-01-11 19:21:30

标签: react-native react-navigation

我从DrawerNavigator导航到BottomTabNavigator,但无法将道具传递到选项卡导航器的屏幕。

我尝试了将道具传递到我的自定义标签导航器的常用方法,该方法可以正常工作,但是道具没有传递到其中显示的屏幕上。

// My Tab Navigator
const ChargerTabNavigator = createBottomTabNavigator(
  {
    ConnectorDetails: { screen: (props) => {
        // The props are NOT passed to this component
        console.log("ConnectorDetails");
        console.log(props.navigation.state.params);
        console.log(props.screenProps);        
        return (<ConnectorDetails {...props} />);
      } 
    },
    ChartDetails: { screen: (props) => <ChartDetails {...props} /> },
    ChargerDetails: { screen: (props) => <ChargerDetails {...props} /> }
  },
  {
    tabBarPosition: "bottom",
    swipeEnabled: false,
    animationEnabled: true,
    tabBarComponent: (props) => {
      // The props are passed to this component
      console.log("ChargerTab");
      console.log(props.navigation.state.params);
      console.log(props.screenProps);        
      return (<ChargerTab {...props} />);
    }
  }
);

// My Drawer Navigator
const DrawerNavigator = createDrawerNavigator(
  {
    Sites: { screen: Sites },
    SiteAreas: { screen: SiteAreas },
    Chargers: { screen: Chargers },
    ChargerTabNavigator: { screen: ChargerTabNavigator }
  },
  {
    navigationOptions: {
      swipeEnabled: true,
    },
    drawerWidth: Dimensions.get("window").width / 1.5,
    initialRouteName: "Sites",
    drawerPosition: "right",
    contentComponent: props => <Sidebar {...props} />
  }
);

我从站点-> SiteAreas->充电器导航,然后使用以下命令导航到ChargerTabNavigator:

navigation.navigate(“ ChargerTabNavigator”,{my_props})

ChargerTab接收道具,但不接收ConnectorDetails(参见console.log)

有什么主意!?

“ react-native”:“ ^ 0.57.8”, “反应导航”:“ ^ 2.18.3”

0 个答案:

没有答案