Skip to content
This repository was archived by the owner on May 19, 2025. It is now read-only.

Commit 72ed649

Browse files
author
Arkadiy Butermanov
committed
Re-draw calendars when range changes
1 parent 75f78e4 commit 72ed649

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

lib/Calendar.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff 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() {

src/Calendar.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff 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

0 commit comments

Comments
 (0)