Skip to content

Commit be9c77f

Browse files
authored
Merge pull request #1735 from mmarkelov/Optimize_setState_dayPickerContainerStyles_
Optimize setState dayPickerContainerStyles in responsivizePickerPosition
2 parents 8e81a8b + fd1595d commit be9c77f

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/components/DateRangePicker.jsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,11 @@ class DateRangePicker extends React.PureComponent {
318318
responsivizePickerPosition() {
319319
// It's possible the portal props have been changed in response to window resizes
320320
// So let's ensure we reset this back to the base state each time
321-
this.setState({ dayPickerContainerStyles: {} });
321+
const { dayPickerContainerStyles } = this.state;
322+
323+
if (Object.keys(dayPickerContainerStyles).length > 0) {
324+
this.setState({ dayPickerContainerStyles: {} });
325+
}
322326

323327
if (!this.isOpened()) {
324328
return;
@@ -332,7 +336,6 @@ class DateRangePicker extends React.PureComponent {
332336
withFullScreenPortal,
333337
appendToBody,
334338
} = this.props;
335-
const { dayPickerContainerStyles } = this.state;
336339

337340
const isAnchoredLeft = anchorDirection === ANCHOR_LEFT;
338341
if (!withPortal && !withFullScreenPortal) {

0 commit comments

Comments
 (0)