react-native-calendario
react-native-calendario copied to clipboard
Unable to rerender component after changing minDate or startingMonth props
Is there any way to force calender rerender after changing one of its props?
I am trying to control component from screen but coul not manage to. Calendar does not rerender after changing props
const CalenderPicker = ({calendarProps}) => {
const {minDate, maxDate, startingMonth} = calendarProps;
return (
<Calendar
onChange={range =>
console.log({
startDate: moment(range.startDate).utc(),
endDate: moment(range.endDate ?? range.startDate).utc(),
})
}
minDate={minDate}
maxDate={maxDate}
startingMonth={startingMonth}
numberOfMonths={13}
// initialListSize={13}
firstDayMonday
showWeekdays={false}
theme={THEME}
/>
);
};
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. You may also mark this issue as a "discussion" and I will leave this open.
Closing this issue after a prolonged period of inactivity. Fell free to reopen this issue, if this still affecting you.
I'm having this same issue also. I'm using Expo and Next.js, trying to create a calendar component with switchable months (because react-native-calendars wasn't cooperating). I'm rendering one month at a time, and then when the user presses the button, it switches to the next month. The logic is all working correctly, but the startingMonth
prop isn't changing or even working when I set it manually.
I'm having this same issue also. I'm using Expo and Next.js, trying to create a calendar component with switchable months (because react-native-calendars wasn't cooperating). I'm rendering one month at a time, and then when the user presses the button, it switches to the next month. The logic is all working correctly, but the
startingMonth
prop isn't changing or even working when I set it manually.
You could try react-native-month instead
Thanks, I'll check this out. If it doesn't work, then we'll know that it's a problem with react-native-month, so I'll just open an issue there instead.
Yep, It worked. I did have to do a bit of fiddling to figure it out, so for anyone looking to do this in the future: having a state variable date
and then changing date
and using getMonth
and getFullYear
doesn't work (which is a React thing, not a react-native-month
thing). Instead, you need to have two separate state variables (eg: month
and year
) and use those.
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. You may also mark this issue as a "discussion" and I will leave this open.
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. You may also mark this issue as a "discussion" and I will leave this open.
Closing this issue after a prolonged period of inactivity. Fell free to reopen this issue, if this still affecting you.