-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
getCurrentRoutes api in v4? #2978
Comments
Ah crap I thought I had a code example for this, digging around still... Can you try setting up a reducer:
Attach it like so:
Now you can console.log(state) in the function and move around its tree, I think what you are looking for is in there IIRC Looking through the source it doesn't look like currentRouter exists anymore (there IS a currentScene), I'd be curious what you need it for to maybe guide you to an alternate solution? |
i use react native's own navigator now(version 0.39), it has a api called getcurrentroutes, this can get a list include all pushed routes, and i cannot found a similar api in rnrf. |
Actions.state |
@fatfatson is correct. |
But Can i get the Stack size? |
@matteocollina have you looked at the state object as pointed above? you can get the idea of the stack size by that. This is a sample that I got by running the tests from the project: {
"key": "StackRouterRoot",
"isTransitioning": false,
"index": 0,
"routes": [
{
"key": "id-1537858201424-3",
"isTransitioning": true,
"index": 1,
"routes": [
{
"params": {
"init": true,
"param": "1"
},
"routeName": "a",
"key": "id-1537858201424-2"
},
{
"params": {
"error": "",
"param": "2",
"init": true,
"data": "abcde",
"routeName": "c"
},
"routeName": "c",
"key": "id-1537858201424-4"
}
],
"params": {
"init": true
},
"routeName": "b"
}
]
} |
how can i get all route in current route stack in v4? i find some talk about Actions.currentRouter, but i cannot find about currentRouter code in v4 source code.
The text was updated successfully, but these errors were encountered: