How to dynamically mark date
See original GitHub issueDescription
I have a Calender component, where I would like to mark a date which is the next day (nextDay
).
export default class CustomCalender extends React.Component {
render() {
const today = moment().format("YYYY-MM-DD");
const nextWeekDay = moment().add(7, 'days').format("YYYY-MM-DD");
const nextDay = moment().add(1, 'days').format("YYYY-MM-DD");
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}
maxDate={nextWeekDay}
onDayPress={(day) => {
console.log('selected day', day)
}}
markedDates={mark}
/>
</View>
)
}
}
Expected Behavior
How can I use the data of nextDay
for the mark constant instead of ‘2017-08-16’?
Environment
"react": "16.0.0-alpha.12",
"react-native": "^0.47.0",
"react-native-calendars": "^1.5.8",
Issue Analytics
- State:
- Created 6 years ago
- Reactions:1
- Comments:14 (1 by maintainers)
Top Results From Across the Web
How to dynamically populate Calendar marked dates from api
Solution: const CalendarScreen = (props) => { const dispatch = useDispatch(); const access_token = useSelector((state) => state.auth.token); ...
Read more >How to dynamically set marked dates from api in react-native ...
Coding example for the question How to dynamically set marked dates from api in react-native-calendar-strip?-React Native.
Read more >mark multiple dates dynamically react native wix - iTecNote
I'm using react-native-calendars. This library provides ability to mark dates on the calendar once mark parameter is passed to calendar object.
Read more >How to make a dynamic calendar in excel - YouTube
1) Use data validation to make drop down lists for the years and months. 2) Use the DATEVALUE and WEEKDAY formulas to make...
Read more >React and Ionic Calendar Marked day classes Example
When you want to update the shape you can simply use CSS and override the styling: .mbsc-calendar-marks .mbsc-calendar-mark { // you custom override...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@robinlery use it like this:
@sfm2222 @kinza88 This method doesn’t work because will get this wrong structure at the end you. You have to have structure like this:
So, you have to work with your nextDay
array
and change thisarray
toobject
correct structure. Example, try this (updated after @ekowcharles suggestions):