React-native-router-flux: Actions.pop({ popNum: number }) doesnt work anymore

Created on 18 Sep 2017  路  7Comments  路  Source: aksonov/react-native-router-flux

Version

Tell us which versions you are using:

  • react-native-router-flux v4.0.0-beta.21 (v3 is not supported)
  • react-native v0.48.3

Expected behaviour

Actions.pop({ popNum: 2 }) goes 2 scenes back

Actual behaviour

Actions.pop({ popNum: 2 }) goes only one scene back

Most helpful comment

Why not support popNum锛焩4

All 7 comments

Try Actions.popTo('sceneKey') instead (Pops the stack until the)
https://github.com/aksonov/react-native-router-flux/blob/master/docs/API.md#actions

@onrige your suggestion did work for me, thank you.

I do think that the documentation is incorrect - it states:

Actions.pop() will pop the current screen. It accepts following optional params:
{popNum: [number]} allows to pop multiple screens at once

But in my tests, and as reported by @mmaschenko, passing popNum does not work:

Actions.pop({popNum: 2}) // Only pops back one screen

@guarani You are welcome :) Could you give me the link to this docs? I can't find anything in current docs (v4) you talk about, sorry.

Your 100% right, I was looking at (v3) docs and using (v4) 馃檭, sorry.

Why not support popNum锛焩4

how did you implement popNum functionality in v4?

@SaffaShujah

pop: function (props) {
        const {popNum} = props || {}
        if (popNum > 1) {
            const routes = Actions._state && Actions._state.routes
            if (routes && routes.length > popNum) {
                const route = routes[routes.length - popNum - 1]
                //v4 not support props refresh, not sure futrue
                Actions.popTo(route.routeName, props)
                if (Object.keys(props).length > 1) {
                    Actions.refresh(props)
                }
            }
        } else {
            Actions.pop()
            if (props) {
                Actions.refresh(props)
            }
        }
    },
Was this page helpful?
0 / 5 - 0 ratings

Related issues

VictorK1902 picture VictorK1902  路  3Comments

maphongba008 picture maphongba008  路  3Comments

kirankalyan5 picture kirankalyan5  路  3Comments

jgibbons picture jgibbons  路  3Comments

vinayr picture vinayr  路  3Comments