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

Actions.pop({ popNum: number }) doesnt work anymore #2397

Closed
mmaschenko opened this issue Sep 18, 2017 · 7 comments
Closed

Actions.pop({ popNum: number }) doesnt work anymore #2397

mmaschenko opened this issue Sep 18, 2017 · 7 comments

Comments

@mmaschenko
Copy link

mmaschenko commented Sep 18, 2017

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

@onrige
Copy link
Collaborator

onrige commented Sep 18, 2017

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

@guarani
Copy link

guarani commented Oct 22, 2017

@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

@onrige
Copy link
Collaborator

onrige commented Oct 23, 2017

@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.

@guarani
Copy link

guarani commented Oct 24, 2017

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

@huowenxuan
Copy link

Why not support popNum?v4

@ghost
Copy link

ghost commented Jun 26, 2018

how did you implement popNum functionality in v4?

@pureandfresh
Copy link

pureandfresh commented Jul 14, 2018

@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)
            }
        }
    },

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

5 participants