- Notifications
You must be signed in to change notification settings - Fork 395
Closed
Labels
Description
Environment
Platforms
iOS only
Versions
- Android:
- iOS:
- react-native-modal-datetime-picker: ^9.1.0
- react-native-community/datetimepicker: 3.0.4
- react-native: ~0.63.3
- react: 16.13.1
Description
I want to show an alert to the user after they have selected a date.
const handleConfirm = (date) => { alert("A Date has been Picked!"); hideDatePicker(); };
The problem on iOS is that hideDatePicker() will also dismiss the new alert, therefore it'll flash briefly on the screen
Here's a video
Screen.Recording.2020-12-29.at.9.11.14.am.mov
Reproducible Demo
Here is a snack demonstrating the issue - please run on iOS
And if that doesn't work here's the code
import { Button, View, Alert } from "react-native"; import DateTimePickerModal from "react-native-modal-datetime-picker"; const DatePickerModalExample = () => { const [isDatePickerVisible, setDatePickerVisibility] = useState(false); const showDatePicker = () => { setDatePickerVisibility(true); }; const hideDatePicker = () => { setDatePickerVisibility(false); }; const handleConfirm = (date) => { alert("A Date has been Picked!"); hideDatePicker(); }; return ( <View> <Button title="Show Date Picker" onPress={showDatePicker} /> <DateTimePickerModal isVisible={isDatePickerVisible} mode="date" onConfirm={handleConfirm} onCancel={hideDatePicker} /> </View> ); } export default DatePickerModalExample; Thanks! mmazzarolo