简体   繁体   中英

React year picker with min max range

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)}/>

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;
};

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM