I am using react-native-calendars
in my project.I am trying to select multiple dates and trying to change its colors.When I consoled the selected dates I'm getting the selected dates. But I am not able to change its color.Any help is really appreciable thank you.Following is my code
Calendar.js
selectDate(day) {
let selectedDate = day.dateString;
if (this.state.dates[selectedDate]) {
const newDates = this.state.dates;
delete newDates[selectedDate]
this.setState({ dates: newDates });
} else {
const newDates = this.state.dates;
newDates[selectedDate] = [
{ selected: true, startingDay: true, color: '#05A081' },
{ selected: true, endingDay: true, color: '#05A081' },
]
this.setState({ dates: newDates });
console.log("NEW_ARRAY", this.state.dates);
}
}
....
<CalendarList
minDate={Date.now()}
pastScrollRange={24}
futureScrollRange={24}
markingType={'period'}
onDayPress={(day) => this.selectDate(day)}
markedDates={this.state.dates}
/>
Following is the console result
NEW_ARRAY
{2019-09-03: Array(2), 2019-09-04: Array(2), 2019-09-05: Array(2)}
2019-09-03: Array(2)
0: {selected: true, startingDay: true, color: "#05A081"}
1: {selected: true, endingDay: true, color: "#05A081"}
length: 2
2019-09-04: (2) [{…}, {…}]
2019-09-05: (2) [{…}, {…}]