Skip to content

Commit

Permalink
Preserve selectedStartDate in state on props update
Browse files Browse the repository at this point in the history
Currently, in `componentWillReceiveProps`, we always set `selectedStartDate` to be null. This can lead to buggy behavior when selectedStartDate was already set to something:
onefinestay#224
  • Loading branch information
wheywu authored Nov 19, 2020
1 parent c73c92a commit 6a9bf29
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/DateRangePicker.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ const DateRangePicker = createClass({
const nextEnabledRange = this.getEnabledRange(nextProps);

const updatedState = {
selectedStartDate: null,
selectedStartDate: this.state.selectedStartDate,
hideSelection: false,
dateStates: this.state.dateStates && Immutable.is(this.state.dateStates, nextDateStates) ? this.state.dateStates : nextDateStates,
enabledRange: this.state.enabledRange && this.state.enabledRange.isSame(nextEnabledRange) ? this.state.enabledRange : nextEnabledRange,
Expand Down

0 comments on commit 6a9bf29

Please sign in to comment.