why I recieve this error although I make a condition check if the object exists.
Object is possible null or undefined
Code:
{
const inHolidays = useCallback(() => data?.user.holiday_times ? checkIfEmployeeIsInHolidays(data?.user.holiday_times) : null, [data]);
....
inHolidays()
?
<p>Mitarbeiter ist im Urlaub bis zum ${format(new Date(inHolidays().end_time), 'PP', { locale: de })}</p>
:
<p>NOT</p>
}
the error comes here in inHolidays().end_time
${format(new Date(inHolidays().end_time)
Why I get this error ? I make a condition check inHolidays() ? : … but not working