From 3c25009d31d9255688e96e55ecbada25bd057196 Mon Sep 17 00:00:00 2001 From: Idan Wender Date: Mon, 8 Apr 2019 19:49:23 +0300 Subject: [PATCH] fix: prevent un/mounting of date components (#1276) I wanted to make a transition to date elements when they were selected, releasing that a couldn't get the `transition` property working. After some digging to my code and react-big-calendar code, I found that after selecting a date `DateContentRow` un&mount their children components. This happens due to the call of [this](https://github.com/intljusticemission/react-big-calendar/blob/master/src/DateContentRow.js#L121) `renderDummy` happens after setting `needLimitMeasure` to true in `Month.jsx` after the date is changed. ---------------------------- Prevent re-mount of DateContentRow children when date change in the same month * Prevent setting `needLimitMeasure` to true when the month of the date is not changed, in order to prevent unmounting and mounting of all the weeks' components. * Make it possible to add transition to the background of the event when implementing selection of date within the calendar. --- src/Month.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Month.js b/src/Month.js index 2a5771089..112480612 100644 --- a/src/Month.js +++ b/src/Month.js @@ -36,7 +36,7 @@ class MonthView extends React.Component { componentWillReceiveProps({ date }) { this.setState({ - needLimitMeasure: !dates.eq(date, this.props.date), + needLimitMeasure: !dates.eq(date, this.props.date, 'month'), }) } @@ -274,7 +274,7 @@ class MonthView extends React.Component { end: slots[slots.length - 1], action: slotInfo.action, bounds: slotInfo.bounds, - box: slotInfo.box + box: slotInfo.box, }) }