question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Background color day not work

See original GitHub issue

I’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’} />

`

VIDEO EXAMPLE

Thanks.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
tautvilascommented, Jun 2, 2017

Please try this:

selecionarData = (day) => {        
    const {datesMarked} = this.state;
    datesMarked =  {...datesMarked,  [day.dateString]: [{startingDay: true, color: '#42aaf4', selected: true}, {selected: true, endingDay: true, color: '#42aaf4', textColor: 'white'}]};
    this.setState({datesMarked: datesMarked})
}

Make sure that datesMarkes is not being mutated, but treated as immutable variable (so on each change it is being initialized again)

0reactions
AkshitSahanicommented, Mar 23, 2018

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; }

let color;
const calGreen = "#BFE9E6";
const calYellow = "#FBDC98";
const calRed = "#E7808D";

switch (updatedTappedDates[day.dateString]) {
  case 0:
    color = calGreen;
    break;
  case 1:
    color = calYellow;
    break;
  case 2:
    color = calRed;
    break;
  default:
    color = calGreen;
}

// const {selectedDates} = this.state;
// selectedDates = {...selectedDates, [day.dateString]: {selected: true, selectedColor: 'orange'}};
-------if i write these two lines above, based on the solution you provided to vagnerSI, I get an 
            error saying "selectedDates is read-only"-------

// const {selectedDates} = this.state;
// let newSelectedDates = {...selectedDates, [day.dateString]: {selected: true, selectedColor: 
    color}};
          ---- I tried this solution as well but not successful-------

let selectedDates = Object.assign({}, this.state.selectedDates);
selectedDates[day.dateString] = {selected: true, selectedColor: color};
this.setState({selectedDates: selectedDates});
 ------ I tried this solution as well after looking at some of your answers to other people having the 
            same problem, but this one is not successful either ----

};

Read more comments on GitHub >

github_iconTop Results From Across the Web

Css background colour not working - Stack Overflow
But background-color: ffffff;return white color.ie.ffffff means white color. So we can not find any background in the website.
Read more >
FACEBOOK BACKGROUND COLOR NOT WORKING FIX 2022
FACEBOOK BACKGROUND COLOR NOT WORKING FIX 2022 | Fix Background Color Not Working On Facebook ; 00:00 How to fix Facebook background color...
Read more >
How to fix "Facebook background Color is not working" 2022 ...
In this video, you will learn why your facebook background is not working and how to fix it. after watching this video you...
Read more >
Change the background color of your calendar
To change the background color of your calendar, right-click the calendar, point to Color, and then pick the color you want. Have multiple...
Read more >
CSS background color not working - The freeCodeCamp Forum
CSS background color not working ... The container elements are collapsed (0 height) because of the float on the li. You can set...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found