sx and ternary operators --MUI

Viewed 1158

I'm trying to right a ternary operator for my sx in MUI.

Any idea why this isn't working?

sx={{...calendarDayColor, isSameDay(new Date(props.date), new Date(selectedDay)) ?bgcolor:'secondary.main'}}

1 Answers

try this:

sx={{
      ...calendarDayColor,
      bgcolor: isSameDay(new Date(props.date), new Date(selectedDay))
         ? bgcolor
         : 'secondary.main',
    }}

Related