Skip to content

Commit f2cbcc3

Browse files
committed
CalendarProvider - fix 'todayButtonMargins' updates and initial button position when isToday
1 parent 336f694 commit f2cbcc3

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

src/expandableCalendar/Context/Provider.tsx

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import React, {Component} from 'react';
55
import {StyleSheet, Animated, TouchableOpacity, View, StyleProp, ViewStyle} from 'react-native';
66

77
import {toMarkingFormat} from '../../interface';
8+
import {isToday} from '../../dateutils';
89
import {Theme, DateData} from '../../types';
910
import styleConstructor from '../style';
1011
import CalendarContext from './index';
@@ -65,9 +66,21 @@ class CalendarProvider extends Component<Props> {
6566
opacity: new Animated.Value(1)
6667
};
6768

69+
componentDidMount() {
70+
const {date} = this.state;
71+
if (isToday(new XDate(date))) {
72+
this.animateTodayButton(date);
73+
}
74+
}
75+
6876
componentDidUpdate(prevProps: Props) {
69-
if (this.props.date && prevProps.date !== this.props.date) {
70-
this.setDate(this.props.date, UpdateSources.PROP_UPDATE);
77+
const {date} = this.props;
78+
if (date && prevProps.date !== date) {
79+
this.setDate(date, UpdateSources.PROP_UPDATE);
80+
}
81+
82+
if (prevProps.todayBottomMargin !== this.props.todayBottomMargin) {
83+
this.animateTodayButton(this.state.date);
7184
}
7285
}
7386

0 commit comments

Comments
 (0)