react-native-modal icon indicating copy to clipboard operation
react-native-modal copied to clipboard

Modal does not appear in certain screens

Open jasonkang14 opened this issue 6 years ago • 7 comments

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 avatar Aug 27 '20 18:08 jasonkang14

@jasonkang14 Were you able to find a fix for this?

nicknjpconsultingllc avatar Sep 21 '20 17:09 nicknjpconsultingllc

@nicknjpconsultingllc I have not.

jasonkang14 avatar Sep 22 '20 12:09 jasonkang14

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.

sektr63a avatar Jan 05 '21 15:01 sektr63a

I'm still facing this issue. Why was this issue closed?

rubinjohny avatar Jan 13 '21 10:01 rubinjohny

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

EtainLove avatar Feb 04 '21 14:02 EtainLove

same issue here, why this issue closed?

Bhoon-coding avatar Apr 20 '21 07:04 Bhoon-coding

setTimeout helped for me:

useEffect(() => {
    if (!currentUser) {
      setTimeout(() => {
        openModal(EModalName.login);
      }, 500);
    }
  }, [closeModal, currentUser, openModal]);

Not the best, but works

Aziaev avatar Nov 20 '22 20:11 Aziaev