@@ -6,6 +6,7 @@ import DateInput from '../DateInput';
66import { calcFocusDate , generateStyles , getMonthDisplayRange } from '../../utils' ;
77import classnames from 'classnames' ;
88import ReactList from 'react-list' ;
9+ import { shallowEqualObjects } from 'shallow-equal' ;
910import {
1011 addMonths ,
1112 format ,
@@ -32,8 +33,7 @@ class Calendar extends PureComponent {
3233 constructor ( props , context ) {
3334 super ( props , context ) ;
3435 this . dateOptions = { locale : props . locale } ;
35- if ( this . props . weekStartsOn !== undefined )
36- this . dateOptions . weekStartsOn = this . props . weekStartsOn ;
36+ if ( props . weekStartsOn !== undefined ) this . dateOptions . weekStartsOn = props . weekStartsOn ;
3737 this . styles = generateStyles ( [ coreStyles , props . classNames ] ) ;
3838 this . listSizeCache = { } ;
3939 this . isFirstRender = true ;
@@ -133,7 +133,7 @@ class Calendar extends PureComponent {
133133 } ) ;
134134 }
135135
136- if ( JSON . stringify ( prevProps . scroll ) !== JSON . stringify ( this . props . scroll ) ) {
136+ if ( ! shallowEqualObjects ( prevProps . scroll , this . props . scroll ) ) {
137137 this . setState ( { scrollArea : this . calcScrollArea ( this . props ) } ) ;
138138 }
139139 }
@@ -378,24 +378,27 @@ class Calendar extends PureComponent {
378378 minDate,
379379 rangeColors,
380380 color,
381+ navigatorRenderer,
382+ className,
383+ preview,
381384 } = this . props ;
382385 const { scrollArea, focusedDate } = this . state ;
383386 const isVertical = direction === 'vertical' ;
384- const navigatorRenderer = this . props . navigatorRenderer || this . renderMonthAndYear ;
387+ const monthAndYearRenderer = navigatorRenderer || this . renderMonthAndYear ;
385388
386389 const ranges = this . props . ranges . map ( ( range , i ) => ( {
387390 ...range ,
388391 color : range . color || rangeColors [ i ] || color ,
389392 } ) ) ;
390393 return (
391394 < div
392- className = { classnames ( this . styles . calendarWrapper , this . props . className ) }
395+ className = { classnames ( this . styles . calendarWrapper , className ) }
393396 onMouseUp = { ( ) => this . setState ( { drag : { status : false , range : { } } } ) }
394397 onMouseLeave = { ( ) => {
395398 this . setState ( { drag : { status : false , range : { } } } ) ;
396399 } } >
397400 { showDateDisplay && this . renderDateDisplay ( ) }
398- { navigatorRenderer ( focusedDate , this . changeShownDate , this . props ) }
401+ { monthAndYearRenderer ( focusedDate , this . changeShownDate , this . props ) }
399402 { scroll . enabled ? (
400403 < div >
401404 { isVertical && this . renderWeekdays ( this . dateOptions ) }
@@ -426,8 +429,8 @@ class Calendar extends PureComponent {
426429 return (
427430 < Month
428431 { ...this . props }
429- onPreviewChange = { this . props . onPreviewChange || this . updatePreview }
430- preview = { this . props . preview || this . state . preview }
432+ onPreviewChange = { onPreviewChange || this . updatePreview }
433+ preview = { preview || this . state . preview }
431434 ranges = { ranges }
432435 key = { key }
433436 drag = { this . state . drag }
@@ -463,8 +466,8 @@ class Calendar extends PureComponent {
463466 return (
464467 < Month
465468 { ...this . props }
466- onPreviewChange = { this . props . onPreviewChange || this . updatePreview }
467- preview = { this . props . preview || this . state . preview }
469+ onPreviewChange = { onPreviewChange || this . updatePreview }
470+ preview = { preview || this . state . preview }
468471 ranges = { ranges }
469472 key = { i }
470473 drag = { this . state . drag }
0 commit comments