react native custom datetimepicker npm

Solutions on MaxInterview for react native custom datetimepicker npm by the best coders in the world

showing results for - "react native custom datetimepicker npm"
Marie
17 Jan 2019
1import React, { useState } from "react";
2import { Button, View } from "react-native";
3import DateTimePickerModal from "react-native-modal-datetime-picker";
4
5const Example = () => {
6  const [isDatePickerVisible, setDatePickerVisibility] = useState(false);
7
8  const showDatePicker = () => {
9    setDatePickerVisibility(true);
10  };
11
12  const hideDatePicker = () => {
13    setDatePickerVisibility(false);
14  };
15
16  const handleConfirm = (date) => {
17    console.warn("A date has been picked: ", date);
18    hideDatePicker();
19  };
20
21  return (
22    <View>
23      <Button title="Show Date Picker" onPress={showDatePicker} />
24      <DateTimePickerModal
25        isVisible={isDatePickerVisible}
26        mode="time"
27        onConfirm={handleConfirm}
28        onCancel={hideDatePicker}
29      />
30    </View>
31  );
32};
33
34export default Example;
35