Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

React Native Modal Component not visible randomly in iOS (workaround solution provided) #29353

Closed
quantjamespecutus opened this issue Jul 13, 2020 · 6 comments
Labels
Component: Modal Needs: Triage 🔍 Platform: iOS iOS applications. Stale There has been a lack of activity on this issue and it may be closed soon.

Comments

@quantjamespecutus
Copy link

quantjamespecutus commented Jul 13, 2020

Description

In some difficult-to-reproduce circumstances, setting the visible prop of a Modal does not cause the Modal to become visible. This has been reported as an issue multiple times over the past two years, but each time Facebook are closing them without any resolution. I have yet to come across a published workaround. I appreciate this one will likely be closed too, but I wanted to share a workaround for other developers banging their heads against the keyboard first :)

These two are exactly the same issue:
#19345
#20394

React Native version:

    OS: macOS 10.15.4
    CPU: (4) x64 Intel(R) Core(TM) i3-8100B CPU @ 3.60GHz
    Memory: 112.80 MB / 8.00 GB
    Shell: 5.7.1 - /bin/zsh
  Binaries:
    Node: 12.16.1 - /usr/local/bin/node
    Yarn: 1.22.1 - ~/.yarn/bin/yarn
    npm: 6.13.4 - /usr/local/bin/npm
    Watchman: Not Found
  Managers:
    CocoaPods: 1.9.3 - /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: Not Found
  IDEs:
    Android Studio: Not Found
    Xcode: 11.5/11E608c - /usr/bin/xcodebuild
  Languages:
    Python: 2.7.16 - /usr/bin/python
  npmPackages:
    @react-native-community/cli: Not Found
    react: ~16.9.0 => 16.9.0 
    react-native: ~0.61.5 => 0.61.5 

Steps To Reproduce

Provide a detailed list of steps that reproduce the issue.

if this.props.visibilityStatus==true when the parent component mounts, this modal will not be visible on iOS (sometimes), but on a reload, it will then become visible.

<Modal
          visible={this.props.visibilityStatus}
        >

WORKAROUND

As stupid as this seems, this is fixed by replacing the bool with a function that returns the bool. For example:

_amIVisible = () => {
bool = this.props.visibilityStatus
return bool;
}
[...]
<Modal
          visible={this._amIVisible()}
        >

et voila! Now the Modal will always be visible when the visibilityStatus props changes, without requiring a reload.

@hengkx
Copy link

hengkx commented Oct 10, 2020

debug ok. release not work.

@rubinjohny
Copy link

apparently, this is not working.

@haikyuu
Copy link

haikyuu commented Jun 2, 2021

I have the same issue. It appears if I provide visible without the state tracking variable. But the workaround isn't working.

@github-actions
Copy link

This issue is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be closed in 7 days.

@github-actions github-actions bot added the Stale There has been a lack of activity on this issue and it may be closed soon. label May 31, 2023
@github-actions
Copy link

github-actions bot commented Jun 7, 2023

This issue was closed because it has been stalled for 7 days with no activity.

@github-actions github-actions bot closed this as completed Jun 7, 2023
@mianaamirshehzad
Copy link

Does anyone have a solution for it?
I'm using an 'Edit modal' in which I am using a state to set it true for opening the other modal for location pick. The state is being set true but my modal is not being opned on iOS devices.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: Modal Needs: Triage 🔍 Platform: iOS iOS applications. Stale There has been a lack of activity on this issue and it may be closed soon.
Projects
None yet
Development

No branches or pull requests

6 participants