In this final section of this chapter, you'll learn how to implement date/time pickers. React Native has 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.
So, let's start with a date picker component for iOS:
import React from "react";
import PropTypes from "prop-types";
import { Text, View, DatePickerIOS } from "react-native";
import styles from "./styles";
export default function DatePicker(props) {
return (
<View style={styles.datePickerContainer}>
<Text style={styles.datePickerLabel}>{props.label}</Text>
<DatePickerIOS mode="date" {...props} />
</View>
);
}
DatePicker.propTypes = {
label: PropTypes.string
};
There's not a lot to this component; it simply adds a label to the DatePickerIOS component. The Android version of the date picker needs...