Skip to content

Commit

Permalink
Revert "Fix bug that introduced a race condition in consumers (#2373)"
Browse files Browse the repository at this point in the history
This reverts commit a0622b9.
  • Loading branch information
amrocha committed Dec 5, 2019
1 parent e638b2e commit c814d42
Showing 1 changed file with 9 additions and 13 deletions.
22 changes: 9 additions & 13 deletions src/components/DatePicker/DatePicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,18 +65,11 @@ export function DatePicker({
const i18n = useI18n();
const [hoverDate, setHoverDate] = useState<Date | undefined>(undefined);
const [focusDate, setFocusDate] = useState<Date | undefined>(undefined);
const [newRange, setNewRange] = useState<Range | undefined>(undefined);

useEffect(() => {
setFocusDate(undefined);
}, [selected]);

useEffect(() => {
if (newRange) {
onChange(newRange);
}
}, [newRange, onChange]);

const handleFocus = useCallback((date: Date) => {
setFocusDate(date);
}, []);
Expand All @@ -92,13 +85,16 @@ export function DatePicker({
[onMonthChange],
);

const handleDateSelection = useCallback((range: Range) => {
const {end} = range;
const handleDateSelection = useCallback(
(range: Range) => {
const {end} = range;

setHoverDate(end);
setFocusDate(new Date(end));
setNewRange(range);
}, []);
setHoverDate(end);
setFocusDate(new Date(end));
onChange(range);
},
[onChange],
);

const handleMonthChangeClick = useCallback(
(month: Months, year: Year) => {
Expand Down

0 comments on commit c814d42

Please sign in to comment.