I would like to have a file in my React application where I can store constants and functions for the whole app.
I declared it like so:
import dayjs from 'dayjs';
const constantsAndFunctions = {
dateFormat:'DD.MM.YYYY',
dateFormatWrittenOut:'D. MMMM YYYY',
dateFormatSQL:'YYYY-MM-DD',
dateTimeFormatSQL:'YYYY-MM-DD HH:mm',
timeFormatSQL:'HH:mm',
formatDateToWrittenOut : (date) => {
//return dayjs(date).format(self.dateFormatWrittenOut); WHY U NO WORK?!
return dayjs(date).format('D. MMMM YYYY');
},
};
In my function formatDateToWrittenOut
I wanted to call the key dateFormat
, but it seems to be empty. No error messages in the console.
What am I missing out? Or is this idea not good in the first place?