Skip to content

Showing alert then dismissing modal will also dismiss the alert on iOS #512

@cgathergood

Description

@cgathergood

Environment

Platforms

iOS only

Versions

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! 

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions