Background color day not work
See original GitHub issueI’m touching on some days in the calendar, but they are not imediately changing the background colors. It only updates the colors when I change the month back and forth.
`<Calendar
current={minDate}
minDate={minDate}
maxDate={maxDate}
displayLoadingIndicator
onDayPress={this.onDayPress}
markedDates={datesMarked}
theme={{
calendarBackground: ‘#ffffff’,
textSectionTitleColor: ‘#b6c1cd’,
selectedDayBackgroundColor: ‘#7AD8FB’,
selectedDayTextColor: ‘#ffffff’,
todayTextColor: ‘#7AD8FB’,
dayTextColor: ‘#2d4150’,
textDisabledColor: ‘#d9e1e8’,
dotColor: ‘#7AD8FB’,
selectedDotColor: ‘#ffffff’,
base: { width: 20, height: 20, justifyContent: ‘center’ },
text: { marginTop: 0, fontSize: 8.5, }
}}
hideExtraDays={true}
markingType={‘interactive’}
/>
`
Thanks.
Issue Analytics
- State:
- Created 6 years ago
- Comments:5 (2 by maintainers)
Please try this:
Make sure that datesMarkes is not being mutated, but treated as immutable variable (so on each change it is being initialized again)
Hi, I’m encountering the exact same problem. The background color for the dates is not changing unless I press the left or right arrow key to change month.
<Calendar style={{marginTop: 70}} minDate={getDate()} maxDate={getDate(‘max’)} hideExtraDays={true} onDayPress={(day)=>{this.selectDate(day)}} markedDates={this.state.selectedDates} onMonthChange={(month)=>{this.nextMonth(month);}} />
selectDate = (day) => { const {tappedDates} = this.state; let updatedTappedDates = {…tappedDates}; if(updatedTappedDates[day.dateString] && updatedTappedDates[day.dateString] < 2){ updatedTappedDates[day.dateString] += 1; } else if(updatedTappedDates[day.dateString] === 2){ updatedTappedDates[day.dateString] = 0; } else{ updatedTappedDates[day.dateString] = 1; }
};