Skip to content

[Bug]: Crash on iOS when rendering DatePicker inside a custom Modal #942

@hirenitp

Description

@hirenitp

Describe the bug

When using react-native-date-picker inside a Modal on iOS, the app crashes with the following error:
libc++abi: terminating with uncaught exception of type NSException
The crash occurs as soon as the DatePicker is rendered. This does not happen on Android — it works as expected there.

I confirmed that the date prop is being passed as a valid JavaScript Date object on render, yet the crash still occurs on iOS.

Device: iPhone 6s plus / Simulator

Expected behavior

Expected the DatePicker to render normally on iOS, like it does on Android, when shown inside a custom modal.

To Reproduce

<Modal
        animationType={'fade'}
        transparent={true}
        visible={showDateTimePicker}>
        <ModalMainView>
          <ModalMainCardView>
            <DatePicker
              date={new Date()}
              fadeToColor={'none'}
              mode={'datetime'}
              placeholder="Select Date and Time"
              format="MM/DD/YY  h:mm a"
              confirmBtnText="Confirm"
              cancelBtnText="Cancel"
              showIcon={true}
              textColor={theme.colors.black}
              onDateChange={date => setSelectedDateForEdit(date)}
            />
            {renderGotoTodayBtn()}
            <ModalButtonContainer>
              <ModalButtonView>
                <Button
                  label={'Discard'}
                  size={'medium'}
                  height={40}
                  fontSize={17}
                  variant={'grey'}
                  onPress={hideDatePicker}
                />
              </ModalButtonView>
              <ModalButtonView>
                <Button
                  label={'Ok'}
                  size={'medium'}
                  height={40}
                  fontSize={18}
                  variant={'primary'}
                  onPress={saveSelectedDate}
                />
              </ModalButtonView>
            </ModalButtonContainer>
          </ModalMainCardView>
        </ModalMainView>
      </Modal>

Operating System

  • Android
  • iOS

React Native Version

0.80.2

Expo Version (if applicable)

No response

react-native-date-picker version

5.0.12

React Native Architecture

  • Old Architecture (Paper)
  • New Architecture (Fabric)

Relevant log output

Below is logs found in Xcode (16.2) 
[RNDatePicker setDatePickerMode:]: unrecognized selector sent to instance 0x1524a12f0*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[RNDatePicker setDatePickerMode:]: unrecognized selector sent to instance 0x1524a12f0'
libc++abi: terminating with uncaught exception of type NSException

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions