Skip to content

Commit 9eb642b

Browse files
author
Arkadiy Butermanov
committed
Re-draw calendars when range changes
1 parent d5ebc00 commit 9eb642b

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
@@ -88,6 +88,16 @@ var Calendar = (function (_Component) {
8888

8989
onInit && onInit(this.state.date);
9090
}
91+
}, {
92+
key: 'componentWillReceiveProps',
93+
value: function componentWillReceiveProps(nextProps) {
94+
var range = nextProps.range;
95+
var offset = nextProps.offset;
96+
97+
if (range && range['endDate'] && !range['endDate'].isSame(range['startDate'])) {
98+
this.setState({ shownDate: range['endDate'].clone().add(offset, 'months') });
99+
}
100+
}
91101
}, {
92102
key: 'getShownDate',
93103
value: function getShownDate() {

src/Calendar.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,14 @@ class Calendar extends Component {
5353
onInit && onInit(this.state.date);
5454
}
5555

56+
componentWillReceiveProps(nextProps) {
57+
const { range, offset } = nextProps;
58+
59+
if(range && range['endDate'] && !range['endDate'].isSame(range['startDate'])) {
60+
this.setState({ shownDate : range['endDate'].clone().add(offset, 'months') })
61+
}
62+
}
63+
5664
getShownDate() {
5765
const { link, offset } = this.props;
5866

0 commit comments

Comments
 (0)