[英]How to pass an array of dates to react-dates component?
我正在使用DayPickerSingleDateController組件。 我在狀態中的數組中保留了一組待突出顯示的日期。 我在文檔中沒有發現如何將該數組作為prop傳遞給組件(如果可能的話)。
我希望有類似的東西:
<DayPickerSingleDateController highlightedDates={this.state.highlightedDates} />
我該如何實現此功能?
好的,我從故事中找到了它( https://github.com/airbnb/react-dates/tree/master/stories )
import isSameDay from 'react-dates/lib/utils/isSameDay';
...
render() {
...
let datesList = this.state.highlightedDates.map(date => {
return moment(date);
});
...
return (
<DayPickerSingleDateController
isDayHighlighted={day1 => datesList.some(day2 => isSameDay(day1, day2))}
/>
);
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.