Estoy usando react-native-community/datetimepicker para seleccionar una fecha. Funciona bien cuando selecciono una fecha por primera vez. Pero si vuelvo a intentar abrir el selector de fechas, me está dando un error.
A continuación se muestra mi código:
const currentDate = Moment(); const [show, setShow]: any = useState(false); const [changedDate, setChangedDate] = useState<string | null>(null); const onChange = (event: any, selectedDate: any) => { setShow(Platform.OS === 'ios'); setDate(currentDate); var dateInLocal = selectedDate.toLocaleDateString().replace('/', '-'); console.log(dateInLocal); setChangedDate(dateInLocal); }; <View> <Text>{changedDate}</Text> <TouchableOpacity onPress={() => { setShow(true); }}> <Text>open</Text> </TouchableOpacity> </View> {show && ( <DateTimePicker testID="dateTimePicker" value={ changedDate ? new Date(changedDate) : currentDate.toDate() } mode="date" is24Hour={true} display="default" onChange={onChange} /> )}Funciona bien al seleccionar fecha por hora, a continuación se muestra el error que recibo cuando intento abrir el selector de fecha por segunda vez:
No puedo entender lo que estoy haciendo mal... por favor ayuda