The missing native date picker component for android
npm install react-native-date-picker-component-android "react": ">=15.4.2""react-native": ">=0.42.0"
$ npm install react-native-date-picker-component-android --save
$ react-native link react-native-date-picker-component-android
#### Android
1. Open up android/app/src/main/java/[...]/MainActivity.java
- Add import com.bitup.datepickercomponent.RNDatePickerComponentPackage; to the imports at the top of the file
- Add new RNDatePickerComponentPackage() to the list returned by the getPackages() method
2. Append the following lines to android/settings.gradle:
```
include ':react-native-date-picker-component-android'
project(':react-native-date-picker-component-android').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-date-picker-component-android/android')
android/app/build.gradle
3. Insert the following lines inside the dependencies block in :`
`
compile project(':react-native-date-picker-component-android')
javascript
import DatePicker from 'react-native-date-picker-component-android';class YourComponentClass extends Component {
constructor(props) {
super(props)
this.state = { date: '1980-01-01' };
}
render() {
return (
... //other components
style={{ width: 320, height: 300 }}
date={this.state.date}
showCalendar = {true} // if you need to use calendar view, default is false
onChange={(date) => this.setState({ date })} />
...//other components
)
}
}
``