React-NativeCalendar议程没有排毒的testID

时间:2019-02-26 13:52:31

标签: javascript ios react-native detox react-native-calendars

我正在为我的react-native项目使用排毒,它有一个日历组件,使用了react-native-calendar的Agenda组件。我正在为议程组件添加一个testID,但似乎没有一个。 这是我的议程代码。

  <Agenda
    items={this.state.items}
    onDayPress={(day)=>{console.log('day pressed',day)}}
    onDayChange={(day)=>{console.log('day changed')}}
    pastScrollRange={50}
    futureScrollRange={50}
    renderItem={(item, firstItemInDay) => {return (<CalendarEvent EventID={item.EventID} navigation ={this.props.navigation}/>);}}


    renderEmptyDate={() => {return (<EmptyEvent/>);}}
    // specify what should be rendered instead of ActivityIndicator
    //renderEmptyData = {() => {return (<EmptyEvent/>)}}
    rowHasChanged={(r1, r2) => {return r1.text !== r2.text}}
    // By default, agenda dates are marked if they have at least one item, but you can override this if needed
    markedDates={markedDates}
    theme={{
                    backgroundColor: '#203546',
                    calendarBackground: '#203546',
                    textSectionTitleColor: '#ffffff',
                    selectedDayBackgroundColor: '#203546',
                    selectedDayTextColor: '#ffffff',
                    todayTextColor: '#00adf5',
                    dayTextColor: '#ffffff',
                    textDisabledColor: '#ffffff',
                    dotColor: '#ffffff',
                    selectedDotColor: '#ffffff',
                    monthTextColor: '#ffffff',
                    textMonthFontWeight: 'bold',
                    textDayFontSize: 16,
                    textMonthFontSize: 20,
                    textDayHeaderFontSize: 15,
                    agendaDayTextColor: 'white',
                    agendaDayNumColor: 'white',
                    agendaTodayColor: '#00adf5',
                    agendaKnobColor: 'white'
                    }}/>

1 个答案:

答案 0 :(得分:0)

react-native-calendars回购中的快速search显示testID组件仅受CalendarHeader组件支持。

该库提供的其余组件似乎不支持testID,但这并不意味着它们不能。

如果您查看排毒troubleshooting guide来添加testID道具的话,状态是:

  

解决方案:React Native在本机上仅支持testID道具   内置组件。如果您创建了自定义复合组件,   您将必须自己支持此道具。你可能应该   将testID属性传播到您的一个渲染子对象(内置   组件):

很遗憾,Agenda组件不是您自己创建的,因此您对其控件没有太多控制权。您可以采取几种措施:

  1. 创建一个问题,并希望仓库的开发团队中的某人进行所需的更改。
  2. 分叉图书馆。现在,您可以完全控制该组件。您将能够添加所需的testID道具。然后,您可以使用库的分支版本。这可能很有用,但请注意,您将必须维护分叉的存储库。您始终可以将更改作为PR提交,并且可以将其合并到实际版本中。

最快的解决方案显然是选项2。然后,您可以在package.json中使用派生版本,如下所示:

"react-native-calendars": "your_github_name/react-native-calendars"