React-native-calendars: onDayPress is not working rn 0.57.7

Created on 5 Dec 2018  路  11Comments  路  Source: wix/react-native-calendars

after installing react-native-calendars 1.20.1 i accepted that onDayPress callbacks is not working

my rn version is 0.57.7
i disable debug Js remotely, but also nothing

```
// Initially visible month. Default = Date()
markedDates={{
'2018-12-16': {selected: true, marked: true, selectedColor: 'blue'},
'2012-05-17': {marked: true},
'2012-05-18': {marked: true, dotColor: 'red', activeOpacity: 0},
'2012-05-19': {disabled: true, disableTouchEvent: true}
}}
//current={'2018-12-01'}
// Minimum date that can be selected, dates before minDate will be grayed out. Default = undefined
minDate={'2012-05-10'}
// Maximum date that can be selected, dates after maxDate will be grayed out. Default = undefined
maxDate={'2012-05-30'}
// Handler which gets executed on day press. Default = undefined
onDayPress={(day) => {alert(day)}}
// Handler which gets executed on day long press. Default = undefined
onDayLongPress={(day) => {console.log('selected day long', day)}}
// Month format in calendar title. Formatting values: http://arshaw.com/xdate/#Formatting
monthFormat={'MM yyyy'}
// Handler which gets executed when visible month changes in calendar. Default = undefined
onMonthChange={(month) => {console.log('month changed', month)}}
// Hide month navigation arrows. Default = false
hideArrows={false}
// Replace default arrows with custom ones (direction can be 'left' or 'right')
// renderArrow={(direction) => ()}
// Do not show days of other months in month page. Default = false
hideExtraDays={true}
// If hideArrows=false and hideExtraDays=false do not switch month when tapping on greyed out
// day from another month that is visible in calendar page. Default = false
disableMonthChange={false}
// If firstDay=1 week starts from Monday. Note that dayNames and dayNamesShort should still start from Sunday.
firstDay={1}
// Hide day names. Default = false
hideDayNames={true}
// Show week numbers to the left. Default = false
showWeekNumbers={false}
// Handler which gets executed when press arrow icon left. It receive a callback can go back month
onPressArrowLeft={substractMonth => substractMonth()}
// Handler which gets executed when press arrow icon left. It receive a callback can go next month
onPressArrowRight={addMonth => addMonth()}
/>

```

Most helpful comment

This was the issue for me:
If you set a maxDate or a minDate, be sure that the day you are pressing is after the minDate value and before the maxDate value.

All 11 comments

Same problem.. any fixes?

same problem on android! any fixes?

@onemoredayApp @kyhnlbyrk i have installed another calendar component

same problem on android,
but onDayLongPress worked!
so I use onDayPress and onDayLongPress

+1

BUMP

seems like onLongPress is blocking onPress on TouchableOpacity of <Day>, since not using long press I created a patch and removed it for now.

@bemaverick, I version 1.22.0 working fine for me. RN 0.58.4

onDayPress={day => {
     alert(day.dateString);
}}

This is still happening in RN 0.59.5.

Using both onDayPress and onDayLongPress works, even for short presses.

This was the issue for me:
If you set a maxDate or a minDate, be sure that the day you are pressing is after the minDate value and before the maxDate value.

@ElijahGeorge, Brilliant! Removing max and min dates it worked for me. Many thanks!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Yandamuri picture Yandamuri  路  4Comments

microwin168 picture microwin168  路  4Comments

chapeljuice picture chapeljuice  路  3Comments

akhilsanker picture akhilsanker  路  4Comments

filippoitaliano picture filippoitaliano  路  3Comments