-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
You cannot render into anything but top root #1502
Comments
node_modules/react-native-navigation/android/app/src/main/java/com/reactnativenavigation/layouts/: class SingleScreenLayout & BottomTabsLayout rewrite function : @Override
public void dismissLightBox() {
if (lightBox != null) {
lightBox.dismiss();
// lightBox.hide();
lightBox = null;
}
} |
@lipingruan thanks you |
Does @lipingruan workaround work for you guys? |
@lipingruan's workaround works. |
That will only work if you want to dismiss the lightbox from your screen, meaning by calling However, if you wanna also close the lightbox by tapping in the background (common use case) using this.props.navigator.showLightBox({
screen: screens.lightBox.sort,
style: {
backgroundBlur: 'dark',
backgroundColor: 'rgba(0, 0, 0, 0.7)',
tapBackgroundToDismiss: true,
},
}); @lipingruan's workaround also removes entirely the animation on dismissal. My workaround works for all cases and keeps the animation, see rgommezz@c15bde4. I am concerned if that would imply memory leaks though. @guyca do you have any thoughts on that? It'd likely break previous RN versions as well. |
@rauliyohmc file1: node_modules/react-native/ReactAndroid/src/main/java/com/facebook/react/ReactInstanceManager.java : rewrite function: private void detachViewFromInstance(
ReactRootView rootView,
CatalystInstance catalystInstance) {
UiThreadUtil.assertOnUiThread();
// int tag = rootView.getId();
int tag = rootView.getRootViewTag();
catalystInstance.getJSModule(AppRegistry.class)
.unmountApplicationComponentAtRootTag(tag);
} file2: node_modules/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/NativeViewHierarchyManager.java : rewrite function: protected synchronized void dropView(View view) {
UiThreadUtil.assertOnUiThread();
int tag;
if ( view instanceof ReactRootView ) {
tag = ((ReactRootView) view).getRootViewTag();
} else {
tag = view.getId();
}
if (!mRootTags.get( tag )) {
// For non-root views we notify viewmanager with {@link ViewManager#onDropInstance}
resolveViewManager( tag ).onDropViewInstance(view);
}
ViewManager viewManager = mTagsToViewManagers.get( tag );
if (view instanceof ViewGroup && viewManager instanceof ViewGroupManager) {
ViewGroup viewGroup = (ViewGroup) view;
ViewGroupManager viewGroupManager = (ViewGroupManager) viewManager;
for (int i = viewGroupManager.getChildCount(viewGroup) - 1; i >= 0; i--) {
View child = viewGroupManager.getChildAt(viewGroup, i);
if (mTagsToViews.get(child.getId()) != null) {
dropView(child);
}
}
viewGroupManager.removeAllViews(viewGroup);
}
mTagsToViews.remove( tag );
mTagsToViewManagers.remove( tag );
} it's ok :) detail message in : |
Hey guys |
@guyca Just change the version of react-native to 0.46.4, then run the example, this error will show when hiding light box. |
Any update @guyca? I'm using many lightboxes on my app mostly for loading popup indicator |
[using V2] not too sure how much help it is but i did some debugging and commenting out |
I get this error in any way i want to close lighbox @Override
public void dismissLightBox() {
if (lightBox != null) {
lightBox.dismiss();
// lightBox.hide();
lightBox = null;
}
} my react native version : |
This hacky by @rawrmaan fixed for me public void destroy() {
// content.unmountReactView();
dismiss();
} tank you man |
It's trow error in some devices like lenovo tab3 |
I encounter this with light box when using Android's back button. Also using |
I'm having the same issue |
Also getting this on android, is this being looked at ? Basically can't use lightboxes at all at the moment. |
As epic as this library is, it is making my app pretty much iOS only instead of cross platform. Please !!!!! fix this issue. |
@hemedani Thanks, your workaround works quite nice. But within my lightbox I'm dependent on the
|
beyond two month for fixing a little and irritating bug ... |
+1 Please fix this issue. I can't use lightbox in my project. |
I'm having exactly same issue. |
any update @guyca on this issue? |
@fliPmitKlammern yeah, there is a racing problem between the hiding animation and the native Dialog destroying. @Override
public void dismissLightBox() {
if (lightBox != null) {
// lightBox.hide();
lightBox.dismiss();
lightBox = null;
}
} However, as my self verification, all this workaround is not stable. Sometime, RN still claims for missing view tag. So I think you should not go with this solution. Sorry for proposing this and wasting your time. I've migrated all my lightbox needs to use my own version which employed the RN Modal component and deliver the same result without animation effects. |
I end up with custom lightbox which base on React native modal |
There is no way I am going to use this lib for any future project. All the cool features that lured me into this are all buggy. For some reason this keeps getting closed even though there is no fix |
@ODelibalta There is no need to get emotional. This issue is still open and nobody closed it. You are probably talking about referenced issues which got closed because they are duplicates of this one. The maintainers are doing this for free and they don't get any profit from whiny people. Like with any other open source project, feel free to fix it yourself and actually give the authors something back for their work. |
If some of you, like me, are tired of updating the file every time, you can use this postinstall script to apply the workaround:
I am willing to debug this as soon as I have some time, because I believe with this we are causing a memory leak. |
I confirm the current workaround is causing a memory leak. The root container that uses to display the Lightbox is not unmounting properly. Every time you start a new Lightbox, a new container was created and keep in the root nodes list causing the leak. You could see this clearly by using this debugger feature |
Okay guys. I am not an Android guy but I downloaded Android Studio and dug around in RNN as well as RN code and I think I have figured this out. Problem is that when Commenting out said line fixes the problem for me. But I don't know about you guys. I don't even know why they needed to set an id in the first place. Maybe in RN < 0.44 I encourage you all to try my fix and if it really fixes the bug(I am skeptical) I will submit a PR and hope @guyca comes around to merge it. |
Well, 0.45.1 launched around June, which is at the same time this commit was issued. I think this was a problem before, but RN was not complaining and cleaning the screen anyway. So, right now is just throwing the error. Can't confirm tho. facebook/react-native@54f7ae1#diff-a04970ddd4a6df34e2245d37f78486e3 |
@hhunaid's solution seems to be working for me without any other issues. Will update if I notice anything strange. |
@hhunaid's solution seems also to work for me but sometimes lightbox content is not displayed (there is only the lightbox background that can be touched to dismiss the lightbox, but no React component). |
Same issue. It was happening about 1 every 10 clicks in my debug build but as soon as I made the release build, it is happening like 2 every 3 clicks. Almost renders the Lightbox not usuable, but I am not sure if this was a problem before. |
I am using RN 0.49.5 and I experience no issues with @hhunaid's solution, neither in debug nor in release mode. |
@hhunaid :
|
I guess it has something to do with that 0.50 patch then. Can you confirm that undoing my patch fixes the view not showing up issue? |
This is my dependencies: @Jay1337 Do you see any of your dependencies in my list? Maybe is another module messing around.
If I remove the patch from @hhunaid I sometimes get this and crashes my app:
But if I use the first workaround, and remove the line that unmounts the component, I still get the dimmed background and no lightbox sometimes. I am thinking the fact that the Lightbox starts a new root view is not helping. |
My patch has nothing to do with this problem then. I thought it might have been a problem with 0.50 infinite layout rendering patch but you are sitting at RN 0.48. So its definitely something else. |
@sfratini This tool is more convenient to make a local patch: https://github.com/ds300/patch-package |
Seems to be broken with react-native: 0.50.3 still. However @ywongweb 's suggestion to use background opacity works nicely. Granted, the Navigator.OS handling is a pain, but showModal in IOS with "screenBackgroundColor: transparent" doesn't seem to work. So I opted to:
and then displaying the modal with a positioned absolute behind all other elements with onPress={closeModal} Setting the dismissModal to display "fade" animation makes the whole thing behave smoothly:
|
Too unstable for me, so I switched to regular RN modals. |
Thanks @guyca for fixing this 🎉🎉🎉 |
I get this error after update RN. The showLightBox is not shown
Environment
The text was updated successfully, but these errors were encountered: