React-native-router-flux: Cannot pop twice

Created on 10 Jun 2016  路  8Comments  路  Source: aksonov/react-native-router-flux

Version

Tell us which versions you are using (react native 0.26 is required for v3):

  • react-native-router-flux v3.26.16
  • react-native v0.26.3

Expected behaviour

I want to go back twice. I got the stack A -> B -> C, now I want go back to A without reload or reset it from C.

Actions.pop()
Actions.pop()

or

Actions.pop(2)

doesn't work

Actual behaviour

Just go back(pop) once

Steps to reproduce

1.create 3 scenes, A, B, C
2.from A to B, then to C
3.try to go back to A from C

39

Most helpful comment

@esutton
you can use the PR in #806
or you can just use

Actions.pop()
setTimeout(() => {Actions.pop()}, 100)

to pop twice

All 8 comments

Yes, looks like this problem started from React Native 0.26, probably NavigationExperimental API has changed something. As workaround you may use setTimeout(()=>Actions.pop) for 'additional' actions, it should work.

@aksonov thanks, man

How would I pop twice?

I am no JS expert. I literally tried this syntax without achieving any pops:
setTimeout(()=>Actions.pop);

Did I read support for an Actions.pop(2) enhancement coming:
https://github.com/aksonov/react-native-router-flux/pull/806

Using:
"react": "15.0.2",
"react-native": "0.26.2",
"react-native-router-flux": "3.26.20",

@esutton
you can use the PR in #806
or you can just use

Actions.pop()
setTimeout(() => {Actions.pop()}, 100)

to pop twice

To add onto what was said before, you probably want to use this.setTimeout, so you don't end up running into errors if the component unmounts before the function is called.

https://facebook.github.io/react-native/docs/timers.html

@xvalentino thank you.

I was using the syntax @Swordsman-Inaction kindly suggested. However, I was getting crashes on cheap Samsung Galaxy S4 tablets on Android that I suspect _could_ be related. I do not know for sure. Anyway, I went back to single-pops temporarily.

I understand a new RFRF API is coming for multiple pops. I will wait until this API is documented in the README.ms and a new RN release comes out that seems to play well with my other packages.

I must say that multiple pops makes my app much better. For example, when I drill down into a multi-level hierarchal menu made from ListView components, then execute a menu action, multiple are great!

No problem. Let me know how it goes @esutton !

use Actions.popTo() instead

Was this page helpful?
0 / 5 - 0 ratings

Related issues

basdvries picture basdvries  路  3Comments

sreejithr picture sreejithr  路  3Comments

YouYII picture YouYII  路  3Comments

rafaelcorreiapoli picture rafaelcorreiapoli  路  3Comments

sarovin picture sarovin  路  3Comments