Skip to content

Commit

Permalink
Merge pull request #1735 from mmarkelov/Optimize_setState_dayPickerCo…
Browse files Browse the repository at this point in the history
…ntainerStyles_

Optimize setState dayPickerContainerStyles in responsivizePickerPosition
  • Loading branch information
ljharb authored Jul 27, 2019
2 parents 8e81a8b + fd1595d commit be9c77f
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/components/DateRangePicker.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,11 @@ class DateRangePicker extends React.PureComponent {
responsivizePickerPosition() {
// It's possible the portal props have been changed in response to window resizes
// So let's ensure we reset this back to the base state each time
this.setState({ dayPickerContainerStyles: {} });
const { dayPickerContainerStyles } = this.state;

if (Object.keys(dayPickerContainerStyles).length > 0) {
this.setState({ dayPickerContainerStyles: {} });
}

if (!this.isOpened()) {
return;
Expand All @@ -332,7 +336,6 @@ class DateRangePicker extends React.PureComponent {
withFullScreenPortal,
appendToBody,
} = this.props;
const { dayPickerContainerStyles } = this.state;

const isAnchoredLeft = anchorDirection === ANCHOR_LEFT;
if (!withPortal && !withFullScreenPortal) {
Expand Down

0 comments on commit be9c77f

Please # to comment.