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

[v6][Android] Crashes when using mergeOptions to update bottomTab when topBar is present. #6097

Closed
didrikkvanvik opened this issue Apr 1, 2020 · 1 comment · Fixed by #6102

Comments

@didrikkvanvik
Copy link

Issue Description

I have 5 bottomTabs in my application, where we support multiple languages. When changing to another language in the app, the bottom tabs text has to change accordingly. I have therefore tried to update all five tabs using mergeOptions, which works fine for iOS.

Worth mentioning: Only 3 of the 5 bottomTabs has a topBar. Android won't crash if I only update these two tabs.

Error logged:

E/AndroidRuntime: FATAL EXCEPTION: main
    Process: no.entur.debug, PID: 9573
    java.lang.NullPointerException: Attempt to invoke virtual method 'int com.reactnativenavigation.viewcontrollers.topbar.TopBarController.getHeight()' on a null object reference
        at com.reactnativenavigation.presentation.StackPresenter.getTopInset(StackPresenter.java:548)
        at com.reactnativenavigation.viewcontrollers.stack.StackController.getTopInset(StackController.java:407)
        at com.reactnativenavigation.viewcontrollers.ComponentViewController.lambda$getTopInset$0$ComponentViewController(ComponentViewController.java:106)
        at com.reactnativenavigation.viewcontrollers.-$$Lambda$ComponentViewController$kPCPbxWkUW2nnI8TIQgM0jqvgY4.run(Unknown Source:4)
        at com.reactnativenavigation.utils.ObjectUtils.perform(ObjectUtils.java:15)
        at com.reactnativenavigation.viewcontrollers.ComponentViewController.getTopInset(ComponentViewController.java:106)
        at com.reactnativenavigation.viewcontrollers.ComponentViewController.applyTopInset(ComponentViewController.java:100)
        at com.reactnativenavigation.viewcontrollers.-$$Lambda$wlwFhgHcAClBnwsp5rN0pxte4i4.on(Unknown Source:2)
        at com.reactnativenavigation.utils.CollectionUtils.forEach(CollectionUtils.java:93)
        at com.reactnativenavigation.utils.CollectionUtils.forEach(CollectionUtils.java:76)
        at com.reactnativenavigation.viewcontrollers.ParentController.applyTopInset(ParentController.java:159)
        at com.reactnativenavigation.viewcontrollers.-$$Lambda$wlwFhgHcAClBnwsp5rN0pxte4i4.on(Unknown Source:2)
        at com.reactnativenavigation.utils.CollectionUtils.forEach(CollectionUtils.java:93)
        at com.reactnativenavigation.utils.CollectionUtils.forEach(CollectionUtils.java:76)
        at com.reactnativenavigation.viewcontrollers.ParentController.applyTopInset(ParentController.java:159)
        at com.reactnativenavigation.viewcontrollers.-$$Lambda$vVglzgYrWmnbpKcV_M9VjZiqrVQ.run(Unknown Source:2)
        at com.reactnativenavigation.utils.ObjectUtils.perform(ObjectUtils.java:11)
        at com.reactnativenavigation.viewcontrollers.ViewController.onMeasureChild(ViewController.java:348)
        at com.reactnativenavigation.viewcontrollers.bottomtabs.BottomTabsController.onMeasureChild(BottomTabsController.java:181)
        at com.reactnativenavigation.views.BehaviourDelegate.onMeasureChild(BehaviourDelegate.java:24)
        at com.reactnativenavigation.views.BehaviourDelegate.onMeasureChild(BehaviourDelegate.java:9)
        at androidx.coordinatorlayout.widget.CoordinatorLayout.onMeasure(CoordinatorLayout.java:831)

Steps to Reproduce / Code Snippets / Screenshots

I've used the following recommended code, as per the documentation, to update a a bottomTab:

Navigation.mergeOptions('BottomTabsId', {
  bottomTab: {
    ...
  }
});

Since I have to update all five tabs, I've assumed I had to run this mergeOptions for each tab. Seems kind of suboptimal to do this, but.. This works great on iOS, but crashes on Android. It works for a tab that doesn't have a topBar, but crashes if one does exist for that tab.

Environment

  • React Native Navigation version: v6.0.1
  • React Native version: v0.61.4
  • Platform(s) (iOS, Android, or both?): Android
  • Device info (Simulator/Device? OS version? Debug/Release?): Simulator (Debug)
@guyca
Copy link
Collaborator

guyca commented Apr 1, 2020

Hey @didrikkvanvik Please fork the library and push a reproduction to your fork. I'll look into it asap.

@guyca guyca added platform: Android type: accepted/bug user: requires reproduction This issue requires a reproduction before maintainers can work on it labels Apr 1, 2020
@guyca guyca self-assigned this Apr 1, 2020
@guyca guyca removed the user: requires reproduction This issue requires a reproduction before maintainers can work on it label Apr 5, 2020
guyca added a commit that referenced this issue Apr 5, 2020
When mergeOptions is called before a view is created or after it's destroyed, don't attempt to create the view.

Fixes #6097
guyca added a commit that referenced this issue Apr 5, 2020
When mergeOptions is called before a view is created or after it's destroyed, don't attempt to create the view.

Fixes #6097
stachu2k pushed a commit to stachu2k/react-native-navigation that referenced this issue Apr 8, 2020
When mergeOptions is called before a view is created or after it's destroyed, don't attempt to create the view.

Fixes wix#6097
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants