React-native-calendars: undefined is not an object (evaluating 'props.current.getTime')

Created on 18 Jul 2017  路  5Comments  路  Source: wix/react-native-calendars

I'm getting this error: undefined is not an object (evaluating 'props.current.getTime'), when I set markedDates to:
{ '2017-07-19': [ { startingDay: true, color: 'blue', selected: true } ] }

when using CalendarList, it works fine when I use the Calendar.

screen shot 2017-07-18 at 14 06 26

Bug report

Most helpful comment

Hey Tom, i have fixed the problem by setting the current={new Date()}

All 5 comments

hi, could you provide with complete code example that reproduces this bug?

class Screen extends React.Component {


    constructor( props ) {
        super( props );

        this.state = {
            selectedDays: []
        }

    };

    render() {


        return (
            <View style={{position: 'relative',flex: 1,flexDirection: 'column',}}>

                <CalendarList
                    current={'2017-07-19'}
                    minDate={'2017-07-19'}
                    maxDate={'2017-12-19'}
                    onDayPress={ ( day ) => this._onSelect( day ) }     
                    markedDates={ this.state.selected }
                    firstDay={0}
                    onVisibleMonthsChange={(months) => {console.log('now these months are visible', months);}}
                    // Max amount of months allowed to scroll to the past. Default = 50
                    pastScrollRange={0}
                    // Max amount of months allowed to scroll to the future. Default = 50
                    futureScrollRange={50}
                    // Enable or disable scrolling of calendar list
                    scrollEnabled={true}
                    theme={{
                        calendarBackground: '#ffffff',
                        textSectionTitleColor: '#b6c1cd',
                        selectedDayBackgroundColor: '#00adf5',
                        selectedDayTextColor: '#ffffff',
                        todayTextColor: '#00adf5',
                        dayTextColor: '#2d4150',
                        textDisabledColor: '#d9e1e8',
                        dotColor: '#00adf5',
                        selectedDotColor: '#ffffff',
                        arrowColor: 'orange',
                        monthTextColor: 'blue',
                        textDayFontSize: 16,
                        textMonthFontSize: 16,
                        textDayHeaderFontSize: 11
                    }}
                />


            </View>
        );
    };

    _onSelect(day) {
        let selectedDays = {};
        selectedDays[ day.dateString ] = [ { startingDay: true, endingDay: true, color: 'red', selected: true } ];
        this.setState( { selected: selectedDays } );
    }


}

This code produces the error. If I change the element to be not it works fine.

Hey Tom, i have fixed the problem by setting the current={new Date()}

thx for bug report, fixed in 1.5.6

Was this page helpful?
0 / 5 - 0 ratings

Related issues

joaosauer picture joaosauer  路  4Comments

anishtr4 picture anishtr4  路  3Comments

ercpereda picture ercpereda  路  4Comments

chapeljuice picture chapeljuice  路  3Comments

sommeshEwall picture sommeshEwall  路  3Comments