question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Nested TabBar in NavigationStack.

See original GitHub issue

I am trying to do something like this:

const stateNavigator = new StateNavigator([
  {key: 'home'},
  {key: 'notifications'},
  {key: 'tweet', trackCrumbTrail: true},
  {key: 'timeline', trackCrumbTrail: true},
  {key: 'tabs'}
]);
const {home, notifications, tweet, timeline, tabs} = stateNavigator.states;
home.renderScene = () => <Home tweets={getHome()} follows={getFollows()} />;
notifications.renderScene = () => <Notifications follows={getFollows()} />;
tweet.renderScene = ({id}) => <Tweet tweet={getTweet(id)}  />;
timeline.renderScene = ({id}) => <Timeline timeline={getTimeline(id)}  />;

tabs.renderScene = () => {
  return (
    <TabBar bottomTabs={true}>
      <TabBarItem title="Home">
        <Home tweets={getHome()} follows={getFollows()} />
      </TabBarItem>
      <TabBarItem
        title="Notifications"
        badge={getFollows().length}>
        <Notifications follows={getFollows()} />
      </TabBarItem>
    </TabBar>
  );
}

stateNavigator.navigate('tabs');

export default () => {
  return (
    <NavigationHandler stateNavigator={stateNavigator}>
      <NavigationStack />
    </NavigationHandler>
  )
}

We don’t need TabBar to stay at bottom on android when app is navigated to other pages. What we need is something similar to hidesBottomBarWhenPushed on the iOS side. These codes work as expected when navigating to new pages, but crashed when we navigate back to tabs page.

java.lang.IllegalStateException: The specified child already has a parent. You must call removeView() on the child's parent first.
        at android.view.ViewGroup.addViewInner(ViewGroup.java:4419)
        at android.view.ViewGroup.addView(ViewGroup.java:4260)
        at androidx.viewpager.widget.ViewPager.addView(ViewPager.java:1485)
        at android.view.ViewGroup.addView(ViewGroup.java:4200)
        at android.view.ViewGroup.addView(ViewGroup.java:4173)
        at androidx.fragment.app.FragmentManagerImpl.moveToState(FragmentManager.java:1466)
        at androidx.fragment.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManager.java:1784)
        at androidx.fragment.app.FragmentManagerImpl.moveToState(FragmentManager.java:1852)
        at androidx.fragment.app.FragmentManagerImpl.dispatchStateChange(FragmentManager.java:3269)
        at androidx.fragment.app.FragmentManagerImpl.dispatchActivityCreated(FragmentManager.java:3229)
        at androidx.fragment.app.Fragment.performActivityCreated(Fragment.java:2466)
        at androidx.fragment.app.FragmentManagerImpl.moveToState(FragmentManager.java:1483)
        at androidx.fragment.app.FragmentManagerImpl.addAddedFragments(FragmentManager.java:2646)
        at androidx.fragment.app.FragmentManagerImpl.executeOpsTogether(FragmentManager.java:2416)
        at androidx.fragment.app.FragmentManagerImpl.removeRedundantOperationsAndExecute(FragmentManager.java:2372)
        at androidx.fragment.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:2273)
        at androidx.fragment.app.FragmentManagerImpl$1.run(FragmentManager.java:733)
        at android.os.Handler.handleCallback(Handler.java:754)
        at android.os.Handler.dispatchMessage(Handler.java:95)
        at android.os.Looper.loop(Looper.java:163)
        at android.app.ActivityThread.main(ActivityThread.java:6276)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:898)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:788)

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:14 (14 by maintainers)

github_iconTop GitHub Comments

1reaction
emerson233commented, Oct 31, 2019

I see. Thanks for your reply.

0reactions
grahammendickcommented, Aug 8, 2020
Read more comments on GitHub >

github_iconTop Results From Across the Web

Hiding tab bar with nested navigation - react native
I used nested navigation for my problem. Currently, however, the tab bar is only displayed on pages listed in TabNavigator.
Read more >
Nesting navigators - React Navigation
Stack navigators nested inside each screen of tab navigator - The tab bar is always visible. Usually pressing the tab again also pops...
Read more >
Stack nested inside bottom tab breaks after tab switch #6642
Just create a bottom tab bar navigator (not material) which render a simple screen and a stack ... @react-navigation/stack, ^5.0.0-alpha.54.
Read more >
BigBinary Books - Using Nested Navigators
A Stack Navigator provides a way for your app to transition between screens where each new screen is placed on top of a...
Read more >
Nesting Tab and Stack Navigators in React Native and Expo ...
This package will allow the app to have a simple tab bar appear at the bottom of the screen and switch between different...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found