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.

selected day background color and text color not changing on press

See original GitHub issue

Description

doing calendar with multi dot marking. selectedDayBackgroundColor and selectedDayTextColor not changing on day press

no error messages

Environment

Please run these commands in the project folder and fill in their results:

  • npm ls react-native-calendars: react-native-calendars@1.1276.0
  • npm ls react-native: react-native@0.64.3

Also specify:

  1. Device/emulator/simulator & OS version: working on expo go

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:10

github_iconTop GitHub Comments

2reactions
Inbal-Tishcommented, Oct 18, 2022

@cgrady3 If you’re passing these keys in the theme prop you should know that it’s not dynamic. The theme prop is passed once to the stylesheet and is not updated by a state change. In your case, where you want to change the SELECTED day background and text colors, I’ll suggest using the markedDates prop. To the selected date you can pass selectedColor and selectedTextColor keys which will change dynamically as the selected date changes. For example:

  const [selected, setSelected] = useState(INITIAL_DATE);
  const [bgColor, setBgColor] = useState('blue');
  const [textColor, setTextColor] = useState('red');

  const onDayPress = useCallback((day) => {
    setSelected(day.dateString);
    setBgColor('orange');
    setTextColor('black');
  }, []);

  const markedDates = useMemo(() => {
    return {
      [selected]: {
        selected: true,
        disableTouchEvent: true,
        selectedColor: bgColor,
        selectedTextColor: textColor
      },
      ['2022-07-22']: {
        dotColor: 'red',
        marked: true
      }
    };
  }, [selected]);
2reactions
DejiAwoniyicommented, Jun 23, 2022

Also facing this issue. has it been solved?

Read more comments on GitHub >

github_iconTop Results From Across the Web

html - select option:checked background color change but ...
Try updating color as. color: #000 ! important;. Yes working for me. Once focus out from select it will work. Please check here....
Read more >
Change how your site looks - Sites Help - Google Support
Point to a section on the page. Then, at the left, click Background Color . · Choose a style or add a photo....
Read more >
How to change background color in Excel based on cell value
Click the Format… button and choose the needed background color on the Fill tab (for detailed instructions, see step 5 of "How to...
Read more >
Changing colors - Squarespace Help Center
Text blocks. The background is set by the section's color theme. To change the block background color: After enabling a block background, click...
Read more >
text-decoration-color - CSS: Cascading Style Sheets | MDN
Color alone should not be used to convey meaning. For example, change of text and text-decoration-color alone is not enough to indicate a ......
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