react-native-modal-datetime-picker is a declarative, cross-platform library that provides a unified user and developer experience for showing native date and time pickers within a modal in React Native applications. It is currently at stable version 18.0.0 and actively maintained, with frequent releases addressing bug fixes, new features, and breaking changes. This library acts as a wrapper around the `@react-native-community/datetimepicker` package, leveraging the underlying native module for iOS and Android while abstracting it into a convenient modal component. Its key differentiator is providing a modal overlay for the native pickers, which can be useful for applications requiring a clear, focused date/time selection interface, integrating seamlessly with both non-Expo and Expo projects.
npm install react-native-modal-datetime-pickerVerified import paths — ran on the pinned version, not inferred.
Demonstrates how to integrate `DateTimePickerModal` to pick a date, manage its visibility with state, and handle confirmation or cancellation. Includes basic styling and platform-specific display options.
Migrate all `defaultProps` declarations directly into component props or apply default values within the component logic itself. Ensure all required props are explicitly passed.
Update `onCancel` handlers to remove any expectation or usage of a `date` parameter. The function should typically only handle hiding the picker.
Review and update TypeScript types for components that use `customCancelButton` or `customConfirmButton` to align with the new type declarations. Check the library's type definitions for the correct interface.
For non-Expo projects, ensure you follow the manual linking steps for `@react-native-community/datetimepicker` in your iOS and Android native projects. For Expo projects, use `npx expo install` which handles linking.
For Expo, set `userInterfaceStyle: 'automatic'` in `app.json`. For bare iOS, consider adding locale forcing in `AppDelegate.m` to ensure proper 24h/12h format and theme alignment. Avoid 'forcing' a theme with `isDarkModeEnabled` if you want it to follow OS settings.
Remove `defaultProps` usage and pass all props explicitly or handle defaults internally.
Adjust the `onCancel` handler signature to not expect a `date` parameter, or handle `undefined` explicitly.
For non-Expo projects, run `npx react-native link @react-native-community/datetimepicker` (if applicable for your RN version) or follow manual linking instructions, then rebuild your native project (`npx react-native run-ios` / `run-android`). For Expo, ensure `npx expo install` was used and clear cache if needed.