This repository was archived by the owner on May 19, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +18
-0
lines changed
Expand file tree Collapse file tree 2 files changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -93,6 +93,16 @@ var Calendar = (function (_Component) {
9393
9494 onInit && onInit ( this . state . date ) ;
9595 }
96+ } , {
97+ key : 'componentWillReceiveProps' ,
98+ value : function componentWillReceiveProps ( nextProps ) {
99+ var range = nextProps . range ;
100+ var offset = nextProps . offset ;
101+
102+ if ( range && range [ 'endDate' ] && ! range [ 'endDate' ] . isSame ( range [ 'startDate' ] ) ) {
103+ this . setState ( { shownDate : range [ 'endDate' ] . clone ( ) . add ( offset , 'months' ) } ) ;
104+ }
105+ }
96106 } , {
97107 key : 'getShownDate' ,
98108 value : function getShownDate ( ) {
Original file line number Diff line number Diff line change @@ -57,6 +57,14 @@ class Calendar extends Component {
5757 onInit && onInit ( this . state . date ) ;
5858 }
5959
60+ componentWillReceiveProps ( nextProps ) {
61+ const { range, offset } = nextProps ;
62+
63+ if ( range && range [ 'endDate' ] && ! range [ 'endDate' ] . isSame ( range [ 'startDate' ] ) ) {
64+ this . setState ( { shownDate : range [ 'endDate' ] . clone ( ) . add ( offset , 'months' ) } )
65+ }
66+ }
67+
6068 getShownDate ( ) {
6169 const { link, offset } = this . props ;
6270
You can’t perform that action at this time.
0 commit comments