Collecting date/time input
In this final section of this chapter, you'll learn how to implement date/time pickers. React Native docs suggest using @react-native-community/datetimepicker
independent date/time picker components for iOS and Android, which means that it is up to you to handle the cross-platform differences between the components. To install datetimepicker
, run the following command in the project:
expo install @react-native-community/datetimepicker
So, let's start with a date picker component for iOS:
import React from "react"; import { Text, View } from "react-native"; import DateTimePicker from "@react-native- community/datetimepicker"; import styles from "./styles"; export default function DatePicker(props) { return ( <View style={styles.datePickerContainer}> <Text style={styles.datePickerLabel}>{props.label} ...