Antd日历不会在状态更改时重新显示

时间:2018-10-08 04:35:19

标签: reactjs antd

即使在状态下更改了绑定到日期单元格渲染方法的值,也不会重新渲染蚂蚁日历通知。

<Calendar className="p-48 pt-64" 
     validRange={[this.state.firstDayOfYear, this.state.lastDayOfYear]}
          onPanelChange={this.onPanelChange} onSelect={this.onSelect} 
            dateCellRender={this.dateCellRender} monthCellRender={this.monthCellRender} />

dateCellRender方法:

dateCellRender(value) {
    //console.log('dateCellRender',value.date(),value.month(),value.year());
    let listData = this.getListData(value.year() + "-" + String(parseInt(value.month()) + 1) + "-" + value.date());
    return (
        <ul className="events">
            {
                listData.map(item => (
                    <li key={item.id}>
                        <div onClick={console.log('item')} style={this.dayColorStyle(item.color)}> {item.content} {item.isWholeDay ? '(Full day)' : "(" + item.from + "-" + item.to + ")"}</div>
                    </li>
                ))
            }
        </ul>
    );

}

getListData功能

getListData(value) {
    var date = moment(value).format('YYYY-MM-DD');
    //console.log('getListData',date);

    let listData = [];
    if (this.state.holidaysOfYear[date]) {
        this.state.holidaysOfYear[date].forEach(function (element) {
            let listElement = {
                id: element.ID_HOLIDAY_POLICY,
                content: element.POLICY_NAME,
                type: 'success',
                color: element.COLOR,
                isWholeDay: element.IS_WHOLE_DAY,
                from: element.FROM_TIME,
                to: element.TO_TIME
            };
            listData.push(listElement);
        });
    }
    //console.log('listData',listData);
    return listData;
}

我的setState holidaysOfYear日历未重新呈现时。

0 个答案:

没有答案