I wanted to know how we can display datepicker on button click in react native. I have tried various solutions still no success,Any help would be helpful. thank you.
Below is what i tried
import React, { Component } from 'react';
import {
Platform,
StyleSheet,
View,DatePicker
} from 'react-native';
This is my render method
render(){
return(
<TouchableOpacity
onPress={() => this.datePicker.onPressDate()}>
<Text>
Hello Date
</Text>
</TouchableOpacity>
<DatePicker
style={{width: 200}}
ref={(picker) => { this.datePicker = picker; }}
date={this.state.date}
mode="date"
placeholder="Select date"
format="YYYY-MM-DD"
minDate="2016-05-01"
maxDate="2020-12-12"
confirmBtnText="OK"
cancelBtnText="Cancel"
onDateChange={(date) => {this.setState({date: date})}}
/>
);
}
whenever i run i get below error
