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

Pressing back button not working as expected #2451

Closed
crossRT opened this issue Oct 1, 2017 · 3 comments
Closed

Pressing back button not working as expected #2451

crossRT opened this issue Oct 1, 2017 · 3 comments

Comments

@crossRT
Copy link

crossRT commented Oct 1, 2017

Version

Tell us which versions you are using:

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

Expected behaviour

When I click the back button, it SHOULD go back to the previous page.

Actual behaviour

When I press the back button, it goes back to the initial page.

Steps to reproduce

I have following scenes:

<Router>
  <Scene key="drawer" contentComponent={this.renderSideBar} drawer>
    <Scene key="splashScreen" component={SplashScreen} initial hideNavBar/>
    <Scene key="login" component={Login} hideNavBar/>
    <Scene key="tripList" component={TripList} title="Trip List"/>
    <Scene key="tripDetails" component={TripDetails} title="Trip Detail" back/>
  </Scene>
</Router>

I enter to tripDetails from tripList, when I click the back button of top left of tripDetails, it goes back to inital Splash Screen page.
I also tried trigger Actions.pop() with the onLeft event, but it's the same.
My problem is: how should I make the "back" function working like usual, going back to the previous page in the stack, which is the tripList page.

@crossRT crossRT changed the title Pressing back button will restart the app Pressing back button not working well Oct 1, 2017
@crossRT crossRT changed the title Pressing back button not working well Pressing back button not working as expected Oct 1, 2017
@mvanroon
Copy link
Contributor

mvanroon commented Oct 3, 2017

I believe this is because they're Drawer child scenes.
Try this:

<Router>
  <Scene key="drawer" contentComponent={this.renderSideBar} drawer>
    <Scene key="splashScreen" component={SplashScreen} initial hideNavBar/>
    <Scene key="login" component={Login} hideNavBar/>
    <Scene key="trips">
      <Scene key="tripList" component={TripList} title="Trip List" initial />
      <Scene key="tripDetails" component={TripDetails} title="Trip Detail" back/>
    </Scene>
  </Scene>
</Router>

@mcabs3
Copy link
Collaborator

mcabs3 commented Oct 4, 2017

@mvanroon is correct, your current setup suggests that both of those Scenes are at the same navigational level, you are expecting them to be in a Stack like navigational structure. Only change is that you shouldn't need the back attribute in tripDetails on his response.

@mcabs3 mcabs3 closed this as completed Oct 4, 2017
@crossRT
Copy link
Author

crossRT commented Oct 5, 2017

got it.
Thank you so much. @mvanroon @mcabs3
=)

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