react-native-paper-datetimepicker
- A datetimepicker for react-native-paper based in web-ridges' react-native-paper-dates
Getting started
Yarn
yarn add react-native-paper-datetimepicker
npm
npm install react-native-paper-datetimepicker --save
Web
If you use react-native-web and want to use this library you'll need to install react-window.
Yarn
yarn add react-window
npm
npm install react-window --save
Usage
;;;
Android Caveats
You will need to add a polyfill for the Intl API on Android if:
- You have Hermes enabled (https://github.com/facebook/hermes/issues/23)
- You have Hermes disabled and you want to support locales outside of en-US and you don't have the org.webkit:android-jsc-intl:+ variant enabled in your app/build.gradle
Install polyfills with Yarn
yarn add react-native-localize @formatjs/intl-pluralrules @formatjs/intl-getcanonicallocales @formatjs/intl-listformat @formatjs/intl-displaynames @formatjs/intl-locale @formatjs/intl-datetimeformat @formatjs/intl-numberformat @formatjs/intl-relativetimeformat
or npm
npm install react-native-localize @formatjs/intl-pluralrules @formatjs/intl-getcanonicallocales @formatjs/intl-listformat @formatjs/intl-displaynames @formatjs/intl-locale @formatjs/intl-datetimeformat @formatjs/intl-numberformat @formatjs/intl-relativetimeformat --save
./index.js
// on top of your index.js fileconst isAndroid = PlatformOS === 'android';const isHermesEnabled = !!globalHermesInternal; // in your index.js fileif isHermesEnabled || isAndroid ; ; ; // use your language files ; ; // use your language files ; ; // use your language files ; ; // use your language files ; ; // use your language files ; ; // use your language files ; ; // https://formatjs.io/docs/polyfills/intl-datetimeformat/#default-timezone let RNLocalize = ; if '__setDefaultTimeZone' in IntlDateTimeFormat IntlDateTimeFormat;
Contributing
This package is a stop-gap solution until we have a datetimepicker on web-ridges' pacckage. Please contribute there.
License
MIT
Credit
Code heavily borrowed from react-native-paper-dates.