We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Possible to put a limit to the range selection?
The text was updated successfully, but these errors were encountered:
yes. There is minDate and maxDate prop for it.
minDate
maxDate
Sorry, something went wrong.
You can achieve it with this workaround
const [state, setState] = useState({ startDate: new Date(), endDate: new Date(), key: "your-key" }); const [focusedRange, setFocusedRange] = useState([0, 0] as RangeFocus); const [selecting, setSelecting] = useState(false); // Selection limited min/max Dates const minDateLimit = addDays(state.startDate, -DAYS_LIMIT + 1) const maxDateLimit = addDays(state.startDate, DAYS_LIMIT - 1) const minDate = selecting ? minDateLimit : addDays(new Date(), -300) const maxDate = selecting ? maxDateLimit : addDays(new Date(), 900) const handleFocusChange = (newFocusedRange: RangeFocus) => { setFocusedRange(newFocusedRange); if (newFocusedRange[1] === 1) setSelecting(true); else setSelecting(false); }; return ( <DateRange ranges={[state]} focusedRange={focusedRange} onRangeFocusChange={handleFocusChange} minDate={minDate} maxDate={maxDate} // *other props* /> );
I hope it helped :))
No branches or pull requests
Possible to put a limit to the range selection?
The text was updated successfully, but these errors were encountered: