react-native - 如何修复 react-native-events-calendar 错误
问题描述
我正在使用https://github.com/joshjhargreaves/react-native-event-calendar 在本机反应中制作一个简单的日视图日历。
我有一个外部平板电脑用于使用 Expo 进行测试。运行我的应用程序时,平板电脑上的堆栈跟踪显示错误:
,但我似乎无法在文件中找到此错误的位置。VS code / metro bundler 没有显示这个错误,它显示了一些警告;
Warning: Failed frame type: The frame `frame.length` is marked as required in `VirtualizedList.getItemLayout`, but its value is `undefined`.
Warning: Failed child context type: Invalid child context `virtualizedCell.cellKey` of type `number` supplied to `CellRenderer`, expected `string`.
我使用导入的代码:
<View style={styles.calendarHolder}>
<EventCalendar>
events={this.state.events}
width={width}
initDate={'2017-09-08'}
</EventCalendar>
</View>
仅当我导入 react-native-events-calendar / 使用它时才会出现此问题。当我不这样做时,我的应用程序工作正常,所以它应该与日历有关。但是,我找不到很多文档,而且由于我也找不到错误的位置,所以我有点卡住了。我怎样才能解决这个问题?对于简单的日视图日历/议程,我也愿意接受其他建议。
解决方案
您错误地定义了 EventCalendar 组件。像下面这样使用它
<EventCalendar
events={this.state.events}
width={width}
initDate={'2017-09-08'}
/>
代替
<EventCalendar>
events={this.state.events}
width={width}
initDate={'2017-09-08'}
</EventCalendar>
推荐阅读
- android - 如何在 Flutter Android 中声明应始终使用最新安装的 ndk 版本?
- jquery - 不能用jquery添加数字
- python - Python 等效于 Stata 命令 iebaltab
- ios - 如何修复 SwiftUI 中多维视图的“索引超出范围”
- android - 浮动操作按钮未正确显示
- javascript - 在没有捆绑程序的情况下将 service worker 更新到 Workbox 5
- sql - Postgresql:“OR”不像我想要的那样工作
- python - 信号分解的机器学习模型
- php - How to create a Woocommerce Product Filter with AJAX?
- php - Laravel WHERE 和 CLAUSE 无法正常工作