-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
swapRange prop was added > > The change adds an optional property to …
…component that allows the functionality of swapping dates if we want to allow the end user to pick dates in any order. This is a real request from the end users, and it will be handy if you work with big date ranges.
- Loading branch information
Showing
4 changed files
with
70 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
() => { | ||
const [startDate, setStartDate] = useState(new Date()); | ||
const [endDate, setEndDate] = useState(null); | ||
const onChange = (dates) => { | ||
const [start, end] = dates; | ||
setStartDate(start); | ||
setEndDate(end); | ||
}; | ||
return ( | ||
<DatePicker | ||
swapRange | ||
selected={startDate} | ||
onChange={onChange} | ||
startDate={startDate} | ||
endDate={endDate} | ||
excludeDates={[addDays(new Date(), 1), addDays(new Date(), 5)]} | ||
selectsRange | ||
selectsDisabledDaysInRange | ||
inline | ||
/> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters