henninghall / react-native-date-picker

React Native Date Picker is datetime picker for Android and iOS. It includes date, time and datetime picker modes. The datepicker is customizable and is supporting different languages. It's written with native code to achieve the best possible look, feel and performance.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[iOS v16.x.x] Fatal Exception: NSInternalInconsistencyException - UITableView dataSource is not set | "UIDatePickerStyleWheels" date picker api crashed

k-saparia opened this issue · comments

Describe the bug

  • App Crashes when the component gets rendered DatePickerIOS on IOS 16 Devices and Simulator

Expected behavior

  • DatePickerIOS should render as expected on all iOS versions

To Reproduce

export default class App extends Component {

  state = { date: new Date() }

  render = () =>
    <DatePicker
      date={this.state.date}
      onDateChange={date => this.setState({ date })}
      mode={"date"}
      locale={'en'}
      style={{
            width: Dimensions.get('window').width,
            height: Dimensions.get('window').height / 3,
            backgroundColor: '#FFF',
          }}
      textColor={'#000000'}
    />

}

Smartphone (please complete the following information):

  • OS: iOS v16.x.x only
  • React Native version [0.72.1]
  • react-native-date-picker version [5.0.0]
image

Workaround

  • If you are using RN > 0.72 and later
  • Check if the date-picker crashes or not. If crashed, try this workaround.
  • Go to iOS folder > DatePicker.m > Replace setup function
-(void)setup {
    if(@available(iOS 13, *)) {
        self.overrideUserInterfaceStyle = UIUserInterfaceStyleLight;
    }
    if (@available(iOS 13, *)) {
        self.preferredDatePickerStyle = UIDatePickerStyleInline; // it will use "Calendar" style date picker for iOS v13 to v16
    } 
    if (@available(iOS 17, *)) {
        self.preferredDatePickerStyle = UIDatePickerStyleWheels; // // it will use traditional (rolling wheels) style date picker for iOS v17 and later
    }
    self.calendar = [NSCalendar calendarWithIdentifier:NSCalendarIdentifierGregorian];
}

@henninghall Please try to reproduce this crash on your side. If issue persists, please update this library with an effective solution. Thanks!

I don't manage to reproduce this. Please provide a repo where this is reproduced, together with name simulator phone name + exact iOS version of the simulator. Thanks