1

I am not sure if this is an error from my code or it's from the react-native-datetimepicker.

Here's how I am using it in my code:

{show && (
  <>
    <DateTimePicker
      value={date}
      mode={mode}
      is24Hour={true}
      onChange={dateOnChange}
    />
    <Button
      title="Submit"
      onPress={() => {
        setShow(false);
      }}
    />
  </>
)}

show is a state, controlled by its mother component. When it's true, the DateTimePicker will show.

Here's a more detailed log of the bug:

enter image description here

I am using expo btw

Eddie Lam
  • 579
  • 1
  • 5
  • 22

3 Answers3

3

If you are using expo, this issue occurs if you a running your app on a device that is running on iOS 14.

To fix it, add a display prop on the date picker just like the example below:

<RNDateTimePicker display="inline" />
Marcelo Dauane
  • 313
  • 3
  • 9
1

Try this command

npx pod-install
Anhdevit
  • 1,926
  • 2
  • 16
  • 29
0

Following the code helps me to resolve my issue.

jest.mock('@react-native-community/datetimepicker', function () {
    const mockComponent = require('react-native/jest/mockComponent')
    return mockComponent('@react-native-community/datetimepicker')
})

A found solution from here

https://github.com/react-native-datetimepicker/datetimepicker/issues/216#issuecomment-741794280

Vishal Dhanotiya
  • 2,512
  • 1
  • 13
  • 32