react-native-calendars
react-native-calendars copied to clipboard
Regression on 1.1278.0, Calendar[OnDayPress]
From version 1.1278.0, on Calendar the onDayPress is not returning the correct date for other months than current.
@VittoriDavide Is this issue still relevant? Can you expand on it?
@Inbal-Tish this is still a problem, listening to the onDayPress
event with the Expandablecalendar
component, but only when it is opened, returning the date but one month before. i'm using the 1.1280.0 version
@Inbal-Tish same issue. Sometimes the onDayPress return the month before the selected. @VittoriDavide @msolanogithub is downgrade to older version fix this problem?
yes I downgraded to an older version to fix this problem
@VittoriDavide @msolanogithub @thp96 Can someone add a code snippet? I'm having a hard time understanding which component and callbacks you're using so I can reproduce this bug.
Hi @Inbal-Tish , I just render the CalendarList component and log the results from onDayPress, click on any date on the calendar and see the month is incorrect. Ex:
- Expect: { day: 6, month: 4, year: 2022 }
- Actual: { day: 6, month: 3, year: 2022 }
@Inbal-Tish here is a snack https://snack.expo.dev/@michael_solano/wix-calendar. Looks like the issue is when the prop date
of CalendarPriver
is not the current date
@msolanogithub Hey. I'm playing with your code in the snack.expo and in our demo app and I don't see what's not working... see my videos. Maybe I don't understand the issue...
Also important, you should NOT connect CalendarProvider's date
prop to the state. It is unnecessary and can cause redundant renders.
https://user-images.githubusercontent.com/33805983/162130929-11ed849b-bfc2-4966-b019-c2ae1a8f68b1.mov
https://user-images.githubusercontent.com/33805983/162130938-05bf02f3-7371-42be-8e14-919b68917315.mov
@Inbal-Tish you are right, with the preview of snack exp it didn't happen, I'm testing with a simulator in IOS 15.2 and iPhone 11 and thanks for the date
prop and the state
https://user-images.githubusercontent.com/38920570/162216895-e5f11e97-a7e5-4d15-802b-9aca62c6f414.mov
For example I was doing like this:
import { Calendar } from 'react-native-calendars';
<Calendar
markingType="period"
theme={calendarTheme}
onDayPress={setDay}
markedDates={periodDay}
current={new Date()}
maxDate={new Date()}
renderArrow={(direction) => {
if (direction === 'left') {
return <ArrowLeft />;
}
return <ArrowRight />;
}}
/>
and here the objDay contained the wrong data:
const setDay = (objDay) => {
const {
dateString,
} = objDay;
I don't think it'll matter but I was using "expo": "^43.0.0"
I was trying to find the bug, maybe here https://github.com/wix/react-native-calendars/commit/3827d8b208c1aa9911d7c5e577316c5c64e91716
@Inbal-Tish you are right, with the preview of snack exp it didn't happen, I'm testing with a simulator in IOS 15.2 and iPhone 11 and thanks for the
date
prop and the stateScreen.Recording.2022-04-07.at.8.43.28.AM.mov
This is exactly what happened in my project!
Does everyone are using expo to reproduce the bug?
@VittoriDavide I tried your code in our demo app and I don't see the issue. When I console objDay
I get the correct day.
Well actually I was using expo, on iOS simulator
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.