How to create React Native Date Piker

In this React Native source code example, the source code below illustrate how to create React Native Date Piker.

You can copy and adopt this source code example to your React Native project without reinventing the wheel.

import React, { Component } from 'react';
import { View, StyleSheet,DatePickerAndroid,Text} from 'react-native'

export default class App extends Component {

  async selectDate(){
    try {
    const {action, year, month, day} = await{
      date: new Date() });
    if (action !== DatePickerAndroid.dismissedAction) {

        } catch ({code, message}) {
          console.warn('Cannot open date picker', message);
   render() {
      return (
         <View style={styles.container}>
           <Text style={{padding: 10,backgroundColor: 'rgb(94, 200, 100)'}}
            onPress={()=>this.selectDate()}>select date</Text>

const styles = StyleSheet.create({
  container: {
    flex: 1,
    alignItems: 'center',
    justifyContent: 'center',
    backgroundColor: '#ddd'

If you have any questions or suggestions kindly use the comment box or you can contact us directly through our contact page below.


Add a Comment