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

Two Back Buttons For The Same Scene #2346

Closed
pedroenriquefreitas opened this issue Sep 7, 2017 · 4 comments
Closed

Two Back Buttons For The Same Scene #2346

pedroenriquefreitas opened this issue Sep 7, 2017 · 4 comments

Comments

@pedroenriquefreitas
Copy link

pedroenriquefreitas commented Sep 7, 2017

Version

  • react-native-router-flux 4.0.0-beta.21
  • react-native v0.47.2

Expected behaviour

I expected the navigator to work normally, creating a navigation between the different scenes, with only one Back Button and the header at the top of the screen.

<Router>
      <Scene key="root">

        <Scene key="main" initial>
          <Scene key="home" component={Home} title="RedManBrasil" />
        </Scene>

        <Scene key="teams">
            <Scene key="league_list" component={LeagueList} title="Leagues" initial />
            <Scene key="team_list" component={TeamList} title="Teams" />
            <Scene key="soloteam" component={Team} />
        </Scene>

      </Scene>
    </Router>

Actual behaviour

sep-07-2017 02-12-45
It creates a blank space above the header, that is misplaced as well. A new back button appears on the screen, working like the one below him. I think this is happening because there is a Scene ( with the key="root") wrapping everything. I had to do this since, when I use the code without it, it gives an error message.

Code Without The Wrapping

    <Router>
        <Scene key="main" initial>
          <Scene key="home" component={Home} title="RedManBrasil" />
        </Scene>

        <Scene key="teams">
            <Scene key="league_list" component={LeagueList} title="Leagues" initial />
            <Scene key="team_list" component={TeamList} title="Teams" />
            <Scene key="soloteam" component={Team} />
        </Scene>
    </Router>

Error Message When It is Not Wrapped
image

@mcabs3
Copy link
Collaborator

mcabs3 commented Sep 7, 2017

@RedManBrasil it is required that you have only a single Scene as a child to Router, so your first lines of code in the beginning of this issue is correct. The two back buttons are appearing because both the root scene and the nested teams scene are controlling their navigators. I would try adding a hideNavBar which will hide a navigator from its scene.

@pedroenriquefreitas
Copy link
Author

pedroenriquefreitas commented Sep 7, 2017

It worked! But this feels like a work around, I remember that wrapping Scene's weren't necessary.

This code, for example, works perfectly

image

@ghost
Copy link

ghost commented Sep 9, 2017

I am encountering the same issue and not sure how to resolve it. I am seeing the issue when I have deeply nested Scenes / Stacks, specifically at the settings stack.

 export default Actions.create(
  <Modal
    hideNavBar
    transitionConfig={() => ({
      screenInterpolator: CardStackStyleInterpolator.forFadeFromBottomAndroid,
    })}>

    <Scene hideNavBar key="landing" component={Landing} />

    <Scene key="auth">
      <Scene hideNavBar key="signup" component={SignUp} />
      <Scene hideNavBar key="login" component={Login} />
    </Scene>

    <Stack key="main" headerMode="screen">

      <Scene initial key="feed" component={Feed} title="App Title" {...feedSceneProps} />

      <Stack key="settings">

        <Scene
          initial
          key="settingsList"
          title="Settings"
          component={Settings}
          {...settingsSceneProps}
        />

        <Scene key="settingsEmail" title="Update Email" component={Email} {...settingsSceneProps} />

        <Scene
          key="settingsPassword"
          title="Change Password"
          component={Password}
          {...settingsSceneProps}
        />

      </Stack>

    </Stack>

  </Modal>,
);

@aksonov
Copy link
Owner

aksonov commented Sep 10, 2017

Each stack has own navBar. All tabs are wrapped within own navbar also. You may disable parent navbar by using hideNavBar or disable wrapping tabs by passing wrap={false} to Tabs scene.

@aksonov aksonov closed this as completed Sep 10, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants