Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
k-saparia opened this issue Apr 9, 2024 · 4 comments

Comments

@k-saparia
Copy link

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
@k-saparia k-saparia changed the title [iOS v16.x.x] Fatal Exception: NSInternalInconsistencyExceptionUITableView dataSource is not set [iOS v16.x.x] Fatal Exception: NSInternalInconsistencyException - UITableView dataSource is not set Apr 9, 2024
@k-saparia k-saparia changed the title [iOS v16.x.x] Fatal Exception: NSInternalInconsistencyException - UITableView dataSource is not set [iOS v16.x.x] Fatal Exception: NSInternalInconsistencyException - UITableView dataSource is not set | "UIDatePickerStyleWheels" date picker api crashed Apr 10, 2024
@k-saparia
Copy link
Author

k-saparia commented Apr 10, 2024

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];
}

@k-saparia
Copy link
Author

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

@henninghall
Copy link
Owner

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

@stesvis
Copy link

stesvis commented Jun 26, 2024

I just had this happen in my EXPO app, on iOS. I was selecting the year, and when the spinner stopped, the app crashed.
All I can see in Sentry is NSInternalInconsistencyException: UITableView dataSource is not set:

{
beingPresented: true,
is_window_rootViewController: false,
presentingViewController: UIViewController,
screen: RCTModalHostViewController,
window: <UIWindow: 0x10130b960; frame = (0 0; 375 812); autoresize = W+H; gestureRecognizers = <NSArray: 0x2809cbe70>; layer = <UIWindowLayer: 0x2809cb780>>,
window_isKeyWindow: true,
window_windowLevel: 0.000000
}

I've never reproduced it locally but it happened in release mode. Seems like it happens the first time you try to use it, then it doesn't happen again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants