React Native activeTintColor未应用于所选抽屉项目

Avi*_*Raj 8 javascript reactjs react-native

React Native activeTintColor未应用于所选抽屉项目.我的反应原生导航路线看起来像,

-> DrawerNavigator
   -> StackNavigator
      -> HomeScreen
      -> FirstScreen
      -> SecondScreen
      -> ThirdScreen
Run Code Online (Sandbox Code Playgroud)

routes.js

const RootStack = createStackNavigator(
  {
    Home: { screen: HomeScreen },
    ChapterGroup: { screen: ChapterGroupScreen },
    Chapter: { screen: ChapterScreen },
  }

const DrawerStack = createDrawerNavigator(
  {
    Home: {
      screen: RootStack,
      params: { id: 1 }
    },
    Kural: { screen: ChapterGroupScreen, params: { id: 2 } },
    Detail: { screen: ChapterGroupScreen, params: { id: 3 } }
  }, { contentComponent: DrawerComponent}
}
export default DrawerStack;
Run Code Online (Sandbox Code Playgroud)

我设法通过创建一个新的DrawerComponent来显示侧栏上的First,Second,thirdScreens,它将导航到抽屉项目点击上的相应堆栈屏幕.

DrawerComponent.js

resetStack = route => {
 let pressedDrwaerItem = route.route.key;
 let id = route.route.params.id;
 this.props.navigation.dispatch(
   StackActions.reset({
    index: 1,
    actions: [
      NavigationActions.navigate({
        routeName: "Home"
      }),
      NavigationActions.navigate({
        routeName: "ChapterGroup",
        params: { title: pressedDrwaerItem, no: id }
      })
    ]
  })
);
}

render() {
      return (<ScrollView>
              <DrawerItems
              {...this.props}
              onItemPress={this.resetStack}
            </DrawerItems</ScrollView>)
    }
Run Code Online (Sandbox Code Playgroud)

它正确地导航到Home堆栈上的ChapterGroup屏幕,但抽屉activeitem指向的Home不是第二个或第三个自定义名称.我想这可能是因为Rootstack中存在所有其他屏幕.无论如何都要手动将第二个抽屉项目设置为活动状态?

DrawerNavigator内部的任何成功实施StackNavigator?即.我想使用堆栈导航器中的两个屏幕作为抽屉项目.如果我们从主屏幕导航到该特定屏幕,则应选择相应的抽屉项目.

Rav*_*avi 4

不确定你是否尝试过contentOptions,但这是我从反应导航文档中找到的

DrawerItems 的内容选项

有多种属性可以与 contentOptions 一起使用

contentOptions: {
  activeTintColor: '#e91e63',
  itemsContainerStyle: {
    marginVertical: 0,
  },
  iconContainerStyle: {
    opacity: 1
  }
}
Run Code Online (Sandbox Code Playgroud)

从上面的片段我想对你activeTineColor可能有用。