Migrate from react-native-date-picker
react-native-date-picker draws native wheels, so it needs a development build and has no web support. Patine UI draws the same wheels in JavaScript: it runs in Expo Go, ships in OTA updates and works on the web. Each platform gets its own design by default (wheels on iOS, a calendar and clock dial in Material, a calendar and time columns on the web); add display="wheel" to keep wheels everywhere.
- import DatePicker from 'react-native-date-picker';
+ import { DatePickerSheet, DateWheelPicker, TimePicker } from 'patine-ui';
- <DatePicker mode="date" date={date} onDateChange={setDate} />
+ <DateWheelPicker value={date} onValueChange={setDate} />
- <DatePicker mode="time" date={time} onDateChange={setTime} minuteInterval={5} />
+ <TimePicker display="wheel" value={time} onValueChange={setTime} minuteInterval={5} />
- <DatePicker
- modal
- open={open}
- date={date}
- onConfirm={(d) => {
- setOpen(false);
- setDate(d);
- }}
- onCancel={() => setOpen(false)}
- />
+ <DatePickerSheet display="wheel" open={open} value={date} onConfirm={setDate} onOpenChange={setOpen} />
| react-native-date-picker | Patine UI |
|---|---|
mode="date" | DateWheelPicker, or DatePicker for a calendar |
mode="time" | TimePicker with display="wheel" |
mode="datetime" | DateTimePicker with display="wheel" |
modal + open | DatePickerSheet / TimePickerSheet / DateTimePickerSheet with open |
date | value |
onDateChange | onValueChange |
onConfirm(date) | onConfirm(date); onOpenChange(false) is called right after, so you don't close it yourself |
onCancel | onOpenChange(false) |
title | title |
confirmText / cancelText | confirmLabel / cancelLabel |
minimumDate / maximumDate | minDate / maxDate |
minuteInterval | minuteInterval |
locale | locale (names and order from Intl) |
is24hourSource | format="12h" or "24h" (default 'auto', from the locale) |
theme="light" | "dark" | "auto" | <PatineProvider colorScheme="light" | "dark" | "auto"> |
dividerColor / buttonColor | theme={{ colors: { indicator, primary } }} |
| A button that opens the modal | DatePickerField / TimePickerField / DateTimePickerField, which hold the open state and show the value |
See all migration guides for other libraries, and Comparison for when another library is the better choice.