React Native Date Picker With Custom Modal

It’s common to see the date picker on a page form in the mobile app containing one or more date fields. Whether it’s a person’s date of birth, flight time, a certificate’s expiration date, or the scheduled date of a meeting, you want to ensure the user is providing a valid date.

In addition, a date picker is a useful addition to a form that displays a calendar along with a date entry field, making it easier for app users to schedule events or fill out registration forms.

Most major packages downgrade the date input type for the user to a text input, causing problems in both UI rendering and data formatting. As a result, when a user enters text, formatting problems with the data can occur.

For example, the lack of user information with different date formats worldwide can lead to difficulties in data processing, leading to an error message in the applications.

Choosing The Right Library For A React Native Date Picker

When operating with React Native, applying an external, middle library is frequently vital, so it’s vital to be considerate in selecting the perfect one. When deciding whether to include a third-party library in an app you’re working on, consider the following four criteria: GitHub stars, Activity, Main maintainer, and README file.

Why Use React Native Date Picker ?

In recent days react-native upgrading its latest version of 0.69, but according to this version, all the packages are not upgrading. Some of the libraries are deprecated when searching for a date picker library. Some of the packages are not maintainable as per the recent react-native version, so due to this problem, we have to use a custom date picker to find a different date picker and a good date picker.

Both work on android as well as iOS. During the implementation of the react-native-date picker library, it shows an error that android DatePickerAndroid has been removed from React Native. We found that solution removed and merged with DatePickerIos so that it works only on iOS, not android.

Using @react-native-community/datetimepicker also does not work with the native base because the native base uses a lower version of the @react-native-community/datetimepicker package. Due to these problems, I used a library that was updated nearly that was react-native-date-picker and created a custom modal for UI for iOS and android.

Installation

1. Packages can be downloaded using npm or yarn.

npm install react-native-date-picker

yarn add react-native-date-picker

2. Set up pods.

cd ios && pod install

3. Recreate the project.

npm react-native run-android

npm react-native run-ios

Let’s start with the implementation by Importing necessary packages and parameters, etc.

React Native Date Picker Installation

On import, we have to import Date Picker from the react-native-date-picker package.

Custom Date Picker Component

React Native Date Picker :Custom Date Picker ComponentOn react-native-date-picker, we have to set the mode for getting date view inside our custom  date picker, and date props always the recent date and when we select a new date that was replaced with the selected date.

Custom Modal Component

On UI Prospective we have used modal to show the same UI inside our android and iOS app. and that modal was not provided by that library.

React Native Date Picker: Custom Modal Component

Full Component Of Custom Date-Picker

React Native Date Picker: Full Component Of Custom Date-Picker

 Styles Component

 React Native Date Picker: Styles Component

For a better UI experience we have used here custom styles.

Here are Some Screenshots:

Props For Using Custom Component

  • No need to use everywhere inside the project.
  • Gives better understanding.
  • Make UI user-friendly.
coma

Conclusion

In this blog, we saw and implemented the custom date picker and how to use our projects and props and cons of using a custom date picker.

 

Satyabrata

Tech Expert

Satyabrata is a React Native Developer with around 2.8+ years of experience in developing mobile applications. Skills like developing clean and reusable code, Creating responsive Mobile pages, API integration etc. 

Get in touch for a detailed discussion.

Hear From Our 100+ Customers
coma

Mindbowser helped us build an awesome iOS app to bring balance to people’s lives.

author
ADDIE WOOTTEN
CEO, SMILINGMIND
coma

We had very close go live timeline and MindBowser team got us live a month before.

author
Shaz Khan
CEO, BuyNow WorldWide
coma

They were a very responsive team! Extremely easy to communicate and work with!

author
Kristen M.
Founder & CEO, TotTech
coma

We’ve had very little-to-no hiccups at all—it’s been a really pleasurable experience.

author
Chacko Thomas
Co-Founder, TEAM8s
coma

Mindbowser is one of the reasons that our app is successful. These guys have been a great team.

author
Dave Dubier
Founder & CEO, MangoMirror
coma

Mindbowser was very helpful with explaining the development process and started quickly on the project.

author
Hieu Le
Executive Director of Product Development, Innovation Lab
coma

The greatest benefit we got from Mindbowser is the expertise. Their team has developed apps in all different industries with all types of social proofs.

author
Alex Gobel
Co-Founder, Vesica
coma

Mindbowser is professional, efficient and thorough. 

author
MacKenzie R
Consultant at XPRIZE
coma

Very committed, they create beautiful apps and are very benevolent. They have brilliant Ideas.

author
Laurie Mastrogiani
Founder, S.T.A.R.S of Wellness
coma

MindBowser was great; they listened to us a lot and helped us hone in on the actual idea of the app.” “They had put together fantastic wireframes for us.

author
Bennet Gillogly
Co-Founder, Flat Earth
coma

They're very tech-savvy, yet humble.

author
Uma Nidmarty
CEO, GS Advisorate, Inc.
coma

Ayush was responsive and paired me with the best team member possible, to complete my complex vision and project. Could not be happier.

author
Katie Taylor
Founder, Child Life On Call
coma

As a founder of a budding start-up, it has been a great experience working with Mindbower Inc under Ayush's leadership for our online digital platform design and development activity.

author
Radhika Kotwal
Founder of Courtyardly
coma

The team from Mindbowser stayed on task, asked the right questions, and completed the required tasks in a timely fashion! Strong work team!

author
Michael Wright
Chief Executive Officer, SDOH2Health LLC
coma

They are focused, patient and; they are innovative. Please give them a shot if you are looking for someone to partner with, you can go along with Mindbowser.

author
David Cain
CEO, thirty2give
coma

We are a small non-profit on a budget and they were able to deliver their work at our prescribed budgets. Their team always met their objectives and I'm very happy with the end result. Thank you, Mindbowser team!!

author
Bart Mendel
Founder, Mindworks
coma

Mindbowser was easy to work with and hit the ground running, immediately feeling like part of our team.

author
George Hodulik
CEO, Stealth Startup, Ex-Google