Reputation: 431
Is there any react year picker which will only pick a year from a given range of the year. If so, how can I do it. I have tried react-datetime. But I couldn't set the range of the year.
<Datetime min={1800} max={2020} dateFormat="YYYY" timeFormat={false} onChange={(date) => this.onChangeExactYear(date)}/>
Upvotes: 1
Views: 1262
Reputation: 535
You should use isValidDate
prop (https://github.com/arqex/react-datetime#blocking-some-dates-to-be-selected)
const isValidDate = current => {
const year = current.year();
return year >= 1800 && year <= 2020;
};
Upvotes: 1