Modal does not appear in certain screens
Environment
System:
OS: macOS 10.15.5
CPU: (12) x64 Intel(R) Core(TM) i7-8750H CPU @ 2.20GHz
Memory: 457.09 MB / 16.00 GB
Shell: 5.7.1 - /bin/zsh
Binaries:
Node: 12.6.0 - /usr/local/bin/node
Yarn: 1.17.3 - /usr/local/bin/yarn
npm: 6.10.3 - /usr/local/bin/npm
Watchman: 4.9.0 - /usr/local/bin/watchman
Managers:
CocoaPods: 1.8.4 - /usr/local/bin/pod
SDKs:
iOS SDK:
Platforms: iOS 13.5, DriverKit 19.0, macOS 10.15, tvOS 13.4, watchOS 6.2
Android SDK:
API Levels: 23, 25, 27, 28, 29
Build Tools: 22.0.1, 27.0.3, 28.0.3, 29.0.2
System Images: android-29 | Google APIs Intel x86 Atom, android-29 | Google Play Intel x86 Atom
Android NDK: Not Found
IDEs:
Android Studio: 3.5 AI-191.8026.42.35.5977832
Xcode: 11.5/11E608c - /usr/bin/xcodebuild
Languages:
Java: 1.8.0_222 - /usr/bin/javac
Python: 3.7.3 - /Users/byeongjinkang/miniconda3/bin/python
npmPackages:
@react-native-community/cli: Not Found
react: 16.8.6 => 16.8.6
react-native: 0.60.5 => 0.60.5
npmGlobalPackages:
*react-native*: Not Found
Platforms
iOS
Versions
- iOS: 9.0
- react-native-modal: 11.5.6
- react-native: 0.60.5
- react: 16.8.6
Description
I am calling the same modal on two different screens. It works fine in one screen, but the modal does not appear on the other screen on iOS while working fine on Android.
I changed the import to import {Modal} from 'react-native' as described in the instruction, but it still did not work.
I checked the values, and I saw that isVisible gets updated even in the modal component. And when I set the initial value of isVisible to true, I can see the modal on the screen in which the modal did not appear when the initial value was set to false.
When I remove the parent Modal component, it works perfectly fine
Reproducible Demo
// Login.tsx
const Login: FunctionComponent<LoginProps> = ({navigation}) => {
...
const loginStatus = useSelector((state: IRootState) => state.authentication.loginStatus)
// this value gets updated using redux-saga
// the value is one of the three 'pending', 'success', 'fail'
...
return (
<ErrorModal isVisible={loginStatus}/>
)
}
// ErrorModal.tsx
import Modal from 'react-native-modal'
type ErrorModalProps = {
isVisible: boolean;
}
const ErrorModal: FunctionComponent<ErrorModalProps> = ({isVisible}) => {
return (
<Modal isVisible={isVisible === 'fail'}>
<ModalContents />
</Modal>
)
}
@jasonkang14 Were you able to find a fix for this?
@nicknjpconsultingllc I have not.
This happens because react-native-screens and react-native-modal libraries conflicts with each other on IOS
You can remove enableScreens() call from react-native-screens and likely it will works.
I'm still facing this issue. Why was this issue closed?
I had the same issue.
It was due to that the modal does not support multiple modals. in my case, nested modals. modal in modal.
I had to show one modal and hide the other. Here i had to use setTimeout to show a modal. // hide a modal // wait a moment (e.g. 500ms) // show the other modal
same issue here, why this issue closed?
setTimeout helped for me:
useEffect(() => {
if (!currentUser) {
setTimeout(() => {
openModal(EModalName.login);
}, 500);
}
}, [closeModal, currentUser, openModal]);
Not the best, but works