xgfe / react-native-datepicker

react native datePicker component for both Android and IOS, useing DatePikcerAndroid, TimePickerAndroid and DatePickerIOS
MIT License
2.12k stars 726 forks source link

IOS 11 Changing Calendar From Gregorian To Buddhist or Japanese, App get Crash when click on the date picker #288

Open ArchanaUdaranga opened 5 years ago

ArchanaUdaranga commented 5 years ago

Issue

App get crash when changing Calendar to non-Gregorian (e.g. Buddhist, Japanese) in following iOS version,

iOS - 10.3.3 - not reproducible 12.0 - not reproducible 11.0.2 - reproducible

Xcode consol log output

Terminating app due to uncaught exception 'NSRangeException', reason: ' -[__NSArrayM objectAtIndex:]: index 9223372036854775807 beyond bounds [0 .. 1]'

Code

import React, {Component} from 'react';
import {View, Text} from 'react-native';
import DatePicker from 'react-native-datepicker'

class DatePickerComponent extends Component {
    constructor(props) {
        super(props)
        this.state = {
            val: null
        }
    }

    onDateChange(val) {
        this.setState({val})
        this.props.onDateChange(val)
    }

    render() {
        return <DatePicker
            style={{width: 200}}
            placeholder={"dd/mm/yyyy"}
            mode="date"
            date={this.state.val}
            format="DD/MM/YYYY"
            minDate="2018-09-01"
            maxDate="2018-10-01"
            confirmBtnText="Confirm"
            cancelBtnText="Cancel"
            customStyles={{
                dateIcon: {
                    position: 'absolute',
                    left: 0,
                    top: 4,
                    marginLeft: 0
                },
                dateInput: {
                    marginLeft: 36
                }
            }}
            onDateChange={this.onDateChange.bind(this)}
        />

    }
}

export default DatePickerComponent;

Environment

  1. react-native -v: 0.43.3
  2. react-native-datepicker : 1.4.7
  3. node -v: v10.10.0
  4. npm -v: 6.4.1
  5. target platform: iOS
  6. Xcode : 9.2