I have a Calender component, where I would like to mark a date which is the next day (nextDay). I am using react-native-calendars.
export default class CustomCalender extends React.Component {
render() {
const today = moment().format("YYYY-MM-DD");
const nextDay = moment().add(1, 'days').format("YYYY-MM-DD"); // 2017-08-29
const mark = {
'2017-08-16': {selected: true, marked: true}
};
return (
<View style={styles.container}>
<Text style={styles.labelText}>Select a date</Text>
<Calendar
minDate={today}
onDayPress={(day) => {
console.log('selected day', day)
}}
markedDates={mark}
/>
</View>
)
}
}
How can I use the data of nextDay
(i.e., 2017-08-29) for the mark constant instead of doing like this '2017-08-16'?
I tried this way:
const mark = {
today: {selected: true, marked: true}
};
But instead of using the value of today
(i.e., 2017-08-29), it uses today
itself as the name of the key.