React native 使用OnVisibleMonSchange响应当月的本机日历更新事件

React native 使用OnVisibleMonSchange响应当月的本机日历更新事件,react-native,react-native-calendars,React Native,React Native Calendars,使用,onVisibleMonthsChange={this.loadItems}不会更新标记日期 我的loadItems功能是: loadItems(months) { const { events, eventsForMonth } = this.props; eventsForMonth(events, months); } <CalendarList style={styles.calendar} c

使用,
onVisibleMonthsChange={this.loadItems}
不会更新标记日期

我的loadItems功能是:

loadItems(months) {
    const { events, eventsForMonth } = this.props;

    eventsForMonth(events, months);
}
        <CalendarList
            style={styles.calendar}
            current={currentDate}
            markingType={"multi-dot"}
            onVisibleMonthsChange={this.loadItems}
            onDayPress={this.onDayPress}
            minDate={currentDate}
            loadingIndicatorColor={"#6da1a6"}
            markedDates={eventsMonth}
            pastScrollRange={0}
            futureScrollRange={6}
            scrollEnabled={true}
            showScrollIndicator={true}
        />
My
eventsMonth
在滚动以正确的格式显示正确的数据后,为什么My month不呈现

{
  "2018-11-24": {},
  "2018-11-25": {},
  "2018-11-26": {},
  "2018-11-27": {},
  "2018-11-28": {},
  "2018-11-29": {},
  "2018-11-30": {},
  "2018-12-01": {
    "dots": [
      {
        "id": 2983,
        "title": "Kiranjit Event",
        "colour": "",
        "textColor": "#000000",
        "organiser": "N/A",
        "description": "",
        "selectedDotColor": "",
        "categories": [
          {
            "name": "Student 1 - Kiranjit Aujla",
            "slug": "student-1-spc",
            "term_group": 0,
            "term_taxonomy_id": 107,
            "taxonomy": "tribe_events_cat",
            "description": "",
            ...
          }
        ],
        "startTime": "08-00",
        "endTime": "17-00"
      }
    ],
    "disabled": false,
    "selected": true,
    "selectedColor": "#00CCCB",
    "customStyles": {
      "text": {
        "marginTop": 3
      }
    }
  },
  "2018-12-02": {},
  "2018-12-03": {}
}

正如您所说的,
eventsMonth
显示了正确的数据,但是在获取该变量中的数据后,您是否刷新了视图或重新提交了视图?因为
onVisibleMonthsChange
只是一个回调,它不会刷新日历。如您所见,
markedDates={eventsMonth}
是传递当前月份数据的道具,您在变量中拥有该数据,但它不会传递给
。因此,您只需要刷新控件buy
this.setState({})
,它就可以工作了。不,我该怎么做?我正在使用
redux
不确定,但在
eventsForMonth(events,months)之后编写
this.setState({})
试过了,还是不走运
{
  "2018-11-24": {},
  "2018-11-25": {},
  "2018-11-26": {},
  "2018-11-27": {},
  "2018-11-28": {},
  "2018-11-29": {},
  "2018-11-30": {},
  "2018-12-01": {
    "dots": [
      {
        "id": 2983,
        "title": "Kiranjit Event",
        "colour": "",
        "textColor": "#000000",
        "organiser": "N/A",
        "description": "",
        "selectedDotColor": "",
        "categories": [
          {
            "name": "Student 1 - Kiranjit Aujla",
            "slug": "student-1-spc",
            "term_group": 0,
            "term_taxonomy_id": 107,
            "taxonomy": "tribe_events_cat",
            "description": "",
            ...
          }
        ],
        "startTime": "08-00",
        "endTime": "17-00"
      }
    ],
    "disabled": false,
    "selected": true,
    "selectedColor": "#00CCCB",
    "customStyles": {
      "text": {
        "marginTop": 3
      }
    }
  },
  "2018-12-02": {},
  "2018-12-03": {}
}