iOS: UI will be blocked when show Alert while closing Modal
See original GitHub issueWhen show Alert while closing Modal, the Alert dialog will disappear and the Modal will block the UI entirely even after reload, only on iOS.
'use strict';
import React, { Component } from 'react';
import {
StyleSheet,
View,
Text,
Modal,
Alert,
} from 'react-native';
class demo extends Component {
state = {
showModal: false,
}
onShowModal = () => {
this.setState({ showModal: true });
}
onCloseModal1 = () => {
this.setState({ showModal: false }, () => {
Alert.alert('Alert', 'UI will be blocked by the modal');
});
}
onCloseModal2 = () => {
this.setState({ showModal: false }, () => {
setTimeout(() => {
Alert.alert('Alert', 'Alert won\'t show');
}, 200);
});
}
onCloseModal3 = () => {
this.setState({ showModal: false }, () => {
setTimeout(() => {
Alert.alert('Alert', 'Works fine');
}, 510);
});
}
render() {
const { showModal } = this.state;
return (
<View style={styles.container}>
<Text onPress={this.onShowModal}>Show modal</Text>
<Modal animationType='slide' visible={showModal} onRequestClose={this.onCloseModal3} >
<View style={styles.container}>
<Text onPress={this.onCloseModal1}>Close modal immediately</Text>
<Text onPress={this.onCloseModal2}>Close modal after 200ms</Text>
<Text onPress={this.onCloseModal3}>Close modal after more then 500ms</Text>
</View>
</Modal>
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
alignItems: 'center',
justifyContent: 'space-around',
},
});
export default demo;
Issue Analytics
- State:
- Created 7 years ago
- Reactions:269
- Comments:184 (39 by maintainers)
Top Results From Across the Web
UI will be blocked when show FancyAlert while closing Modal ...
I am developing an ios and android mobile application using native script angular. I am using the TNSFancyalert plugin to show alert info,...
Read more >iOS 14 (SwiftUI) Sheet Modals not … | Apple Developer Forums
Sometimes a modal is automatically (non-desired) closed right after it opens, and after that, the modal works fine (and so it is not...
Read more >Modal - Chakra UI
A modal is a dialog that focuses the user's attention exclusively on an information via a window that is overlaid on primary content....
Read more >W3.CSS Modal - W3Schools
A modal is a dialog box/popup window that is displayed on top of the current ... To close a modal, add the w3-button...
Read more >JavaScript - Bootstrap
Don't use data attributes from multiple plugins on the same element. For example, a button cannot both have a tooltip and toggle a...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
today I met the similar problem after I upgraded the react-native from 0.33 to 0.37. I want to show an Alert dialog after close the Modal, but Modal doesn’t disappear, even after I close the Alert dialog and use
cmd + R
to reload the app. only in iOS, and it works fine by react-native 0.33.the code likes following:
then I try to use
setTimeout
to work around it, the code likes following:then the Modal will disappear, but, the Alert dialog can’t display!!!
I also tried run
setTimeout
insetState
callback, like this:but the same result, Alert dialog doesn’t pop up yet.
finally, I decide to hide Modal after I close the Alert dialog, and that works! code likes following:
+1