-
Notifications
You must be signed in to change notification settings - Fork 24.4k
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
Modal: Refresh (via dev menu) does not tear down #17986
Comments
Seeing in iOS as well. Adding a state change to take the modal down in componentWillUnmount does nothing |
This comment has been minimized.
This comment has been minimized.
Is there any workaround? This also affects programmatic restarting on codepush updates for example. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This is pretty awful for developing against, but it is still possible to use the modal, so long as you close it before you reload the app. This means you must have a way of closing the modal from the modal itself (IE: a close button), and you must close it before the app reloads... you should also disable live reload and hot reload. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
I guess here's the fix e5c2a66 and will be available in 0.56 |
That fix is also in 0.55.4, and the problem remains (Android emulation at least). It's a blocker for hot/live reloading, therefore for any decent development environment. Can't use this package until it's fixed. |
The above workaround doesn't work. The only workaround I've found is to auto-close the Modal in the dev build after 7 seconds, otherwise it's too easy to hang it. Once it was hung so bad that I had to cold-boot the emulator. This is a must-fix! Note it affects all Modals based on the RN Modal. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Adding this line helps. Any ideas why this is required? |
please then somwone tell how to fix it |
Is there no way to fix this? Still an issue :( |
Are you guys kidding that, after so many RN versions and month since this issue was open, nobody made a fix? |
@EhsanSarshar its not that easy unfortunately, read the entire thread for details |
Confirming, still an issue in RN 0.60.4 |
1 similar comment
Confirming, still an issue in RN 0.60.4 |
We're running into this issue as well. |
Nevermind it's definitely still an issue even with fast refresh. |
No solution for this yet? |
This is also an issue for those of us using codepush. When the app refreshes the js bundle, the previous state modal still shows and completely locks the app. |
Very frustrating, even more so if you don't know what's causing it. Appears to happen when I have nested Modals. Closing the first modal without closing the second (nested) modal also makes the simulator freeze. |
Summary: Fixes #17986 See above issue After apply this change: ![ezgif-4-45d9add85b74](https://user-images.githubusercontent.com/615282/70987576-2520ad00-20fb-11ea-9b90-c9a7839824a5.gif) ## Changelog [Android] [Fixed] - Fix android modal not disappear when reload Pull Request resolved: #27542 Test Plan: Open a modal and do a refresh to see whether it disappears Differential Revision: D19178803 Pulled By: mdvacca fbshipit-source-id: 61894927fc481650804b2196df06a80c16b64e6c
Confirming, still an issue in RN 0.61.5 |
@hongdung6992 The fix will land on 0.62-rc1 |
A compatibility way to fix this problem if you have to use RN 0.60~0.61.(At least work for me) Extend the ReactModalHostView and override the onHostPause method. Then use the new class instead of origin one. You may have to copy many Java files and js files from source code. // Fix the ReactModalHostView
public class ReactModalHostFixedView extends ReactModalHostView {
private Method dismissMethod;
public ReactModalHostFixedView(Context context) {
super(context);
}
@Override
public void onHostPause() {
super.onHostPause();
Method dismiss = this.getDismissMethod();
try {
dismiss.invoke(this);
} catch (InvocationTargetException e) {
Log.e("Demo", "Cant invoke dismiss(InvocationTargetException )");
} catch (IllegalAccessException e) {
Log.e("Demo", "Cant invoke dismiss(IllegalAccessException )");
}
}
protected Method getDismissMethod() {
if (dismissMethod == null) {
try {
Method dismiss = ReactModalHostView.class.getDeclaredMethod("dismiss");
dismiss.setAccessible(true);
dismissMethod = dismiss;
} catch (NoSuchMethodException e) {
Log.e("Demo", "No dismiss method");
}
}
return dismissMethod;
}
} // Fix the ReactModalHostManager
public class ReactModalHostFixedManager extends ReactModalHostManager {
public static final String REACT_CLASS = "RCTModalHostFixedView";
@Override
public String getName() {
return REACT_CLASS;
}
@Override
protected ReactModalHostView createViewInstance(ThemedReactContext reactContext) {
return new ReactModalHostFixedView(reactContext);
}
} // Create you own package and register it in "MainApplication.java"
// See https://facebook.github.io/react-native/docs/native-components-android
public class ReactModalHostFixedPackage implements ReactPackage {
@Override
public List<NativeModule> createNativeModules(ReactApplicationContext reactContext)
{
return Collections.emptyList();
}
@Override
public List<ViewManager> createViewManagers(ReactApplicationContext reactContext)
{
List<ViewManager> managers = new ArrayList<>();
managers.add(new ReactModalHostFixedManager());
return managers;
}
} // You should copy the RCTModalHostViewNativeComponent.js to your project
// from node_modules/react-native/Libraries/Modal/RCTModalHostViewNativeComponent.js
// The preceding codes were omitted
// Notice you have to rewrite the import statements
// Use fixed view if the platform is android
const Platform = require('react-native/Utilities/Platform');
const paperComponentName =
Platform.OS === 'android' ? 'RCTModalHostFixedView' : 'RCTModalHostView';
// export the fixed view
// NOTICE: for RN 0.61.5
export default (codegenNativeComponent<NativeProps>('ModalHostView', {
interfaceOnly: true,
paperComponentName,
}): NativeComponentType<NativeProps>); // You should copy the RCTModalHostViewNativeComponent.js to your project
// from node_modules/react-native/Libraries/Modal/RCTModalHostViewNativeComponent.js
// The preceding codes were omitted
// Notice you have to rewrite the import statements
// Use fixed view if the platform is android
const Platform = require('react-native/Utilities/Platform');
const paperComponentName =
Platform.OS === 'android' ? 'RCTModalHostFixedView' : 'RCTModalHostView';
// export the fixed view
// NOTICE: for RN 0.60.5
module.exports = ((requireNativeComponent(
paperComponentName,
): any): RCTModalHostViewNativeType); // You should copy the Modal.js to your project
// from node_modules/react-native/Libraries/Modal/Modal.js
// Use fixed view above
// The other codes were omitted
import RCTModalHostView from './RCTModalHostViewNativeComponent.js'; It works for me.(Only test on android simulator and my android phone for RN 0.61.5 and RN 0.60.5) |
same problem still in 61.5, i solved it somehow by adding key prop to modal.
you can use any string in key, this fixs duplicate problem in android both emulator and devices. note: same problem also exists in release version android, not just during debug mode. |
@alzalabany this does not solves the issue in my case :( Anyone with another workaround? I am using Code Push and the app is stuck whenever a modal is shown and the code is reloaded |
I found a workaround. Just don't use the modal when the Platform.OS === 'android'. It loses some functionalities like the animation, but you can program does manually if needed. Here is some code I'm using <TouchableHighlight Hope it helps. If anyone needs more help or has any other ideas, just tag me. |
@sunnylqm do you know if it would be possible to merge this fix into 0.61 as well? And is there a time frame for a stable 0.62? |
@WouterFlorijn For release related questions, https://github.com/react-native-community/releases/issues |
It's been almost another whole year and this hasn't been fixed! |
@TKY2048 It's fixed in 0.62 |
For anyone else who is using Expo and is stuck on RN 0.61, this fixed this issue for me:
The |
Summary: Fixes facebook#17986 See above issue After apply this change: ![ezgif-4-45d9add85b74](https://user-images.githubusercontent.com/615282/70987576-2520ad00-20fb-11ea-9b90-c9a7839824a5.gif) ## Changelog [Android] [Fixed] - Fix android modal not disappear when reload Pull Request resolved: facebook#27542 Test Plan: Open a modal and do a refresh to see whether it disappears Differential Revision: D19178803 Pulled By: mdvacca fbshipit-source-id: 61894927fc481650804b2196df06a80c16b64e6c
Is this a bug report?
yes
Have you read the Contributing Guidelines?
kind of
Environment
Environment:
OS: Windows 10
Node: 9.0.0
Yarn: 1.3.2
npm: 5.5.1
Watchman: Not Found
Xcode: N/A
Android Studio: Version 3.0.0.0 AI-171.4408382
Packages: (wanted => installed)
react: 16.2.0 => 16.2.0
react-native: 0.53.0 => 0.53.0
Target Platform: Android 7.0 on Samsung Galaxy S5
Steps to Reproduce
react-native run-android
Expected Behavior
The app closes the modal and refreshes
Actual Behavior
The app presumably refreshes, but the modal stays on top and cannot be closed
Reproducible Demo
The text was updated successfully, but these errors were encountered: