Javascript React NativeCalendar议程没有排毒测试
我正在为我的react native项目使用detox,它有一个日历组件,使用react native calendar中的议程组件。我希望为议程组件添加一个testID,但似乎没有。 这是我的议程代码Javascript React NativeCalendar议程没有排毒测试,javascript,ios,react-native,detox,react-native-calendars,Javascript,Ios,React Native,Detox,React Native Calendars,我正在为我的react native项目使用detox,它有一个日历组件,使用react native calendar中的议程组件。我希望为议程组件添加一个testID,但似乎没有。 这是我的议程代码 <Agenda items={this.state.items} onDayPress={(day)=>{console.log('day pressed',day)}} onDayChange={(day)=>{console.log('day c
<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'
}}/>
快速反应本机calendars repo显示,testID道具仅在CalendarHeader组件中受支持
该库提供的其余组件似乎不支持testID,但这并不意味着它们不能
如果你看一下添加testID道具的排毒方法,你会发现:
解决方案:React Native仅支持本机上的testID道具
内置组件。如果已创建自定义复合构件,
你必须自己支持这个道具。你也许应该
将testID道具传播到一个内置的渲染子对象
组成部分:
不幸的是,议程组件不是您自己创建的,因此您无法控制它的道具。您可以采取以下几项行动:
创建一个问题,并希望repo的开发团队中有人做出您想要的更改。
用叉子叉图书馆。现在,您可以完全控制组件。您将能够添加所需的testID道具。然后可以使用库的分叉版本。这可能有用,但请注意,您必须维护分叉回购。您可以始终将更改作为PR提交,并且它可能会合并到实际版本中。
最快的解决方案显然是方案2。然后,您可以在package.json中使用分叉版本,如下所示:
"react-native-calendars": "your_github_name/react-native-calendars"