Created
May 18, 2020 13:28
-
-
Save dexiouz/e64e6a15a9e48a09f336ce6f37872555 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { useState } from "react"; | |
import { Button, View } from "react-native"; | |
import DateTimePickerModal from "react-native-modal-datetime-picker"; | |
const Example = () => { | |
const [isDatePickerVisible, setDatePickerVisibility] = useState(false); | |
const showDatePicker = () => { | |
setDatePickerVisibility(true); | |
}; | |
const hideDatePicker = () => { | |
setDatePickerVisibility(false); | |
}; | |
const handleConfirm = (date) => { | |
console.warn("A date has been picked: ", date); | |
hideDatePicker(); | |
}; | |
return ( | |
<View> | |
<Button title="Show Date Picker" onPress={showDatePicker} /> | |
<DateTimePickerModal | |
isVisible={isDatePickerVisible} | |
mode="date" | |
onConfirm={handleConfirm} | |
onCancel={hideDatePicker} | |
/> | |
</View> | |
); | |
}; | |
export default Example; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment