react-day-picker: fromMonth not working as expected
My code below is not influencing the fromMonth in any way. Is there a bug or am I doing it wrong?
Render function
render() {
const month = new Date();
month.setMonth(month.getMonth() - 10);
return (
<DayPicker
firstDayOfWeek={ 1 }
onDayClick={ this.handleDayClick }
selectedDays={ day => DateUtils.isDayInRange(day, { from: this.state.from, to: this.state.to }) }
disabledDays={this.disabledDays}
enableOutsideDays={true}
fixedWeeks={true}
numberOfMonths={this.props.numberOfMonths}
toMonth={this.props.disableFuture ? new Date() : null}
fromMonth={month}
/>
);
}
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Reactions: 1
- Comments: 18 (7 by maintainers)
@nealoke maybe you have been hit by this behavior which has been fixed in
v4
. The latest version has few minor breaking changes so it should be easy to upgrade. Could you please upgrade and report back if your issue has been resolved? Thanks!Thanks for the suggestion @lsanwick!
I believe the calendar should always show the current month if the
initialMonth
is not specified, so to prevent confusion about its default behavior. E.g.: the current month is after thetoMonth
, should it display thefromMonth
or thetoMonth
? I’d let the developer choose the behavior.I’d add a note to the docs 👍
@nealoke, you should specify
initialMonth={month}
as well. It defaults to the current month, but I’d argue that the default should be changed to thefromMonth