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
Params with DrawerNavigator #80
Comments
I have the same problem ! |
AFAIK cc @ericvicenti |
This happens not just for the DrawerStack it happens when you try to pass data from into a new stack of any type. Current issue is that the params object is not being passed between stacks and we should easily be able to implement this into React-Navigation. @grabbou |
Working on a fix over the weekend. We will try to land it to next release
…On Fri, Feb 24, 2017, 16:16 Muhammad Usman ***@***.***> wrote:
Any updates on this issue? Still facing it with "react-navigation":
"^1.0.0-beta.5"
No params when using DrawerNavigator
[image: screenshot from 2017-02-24 16-14-22]
<https://cloud.githubusercontent.com/assets/3153380/23308786/989f0c54-faac-11e6-8bd7-0c8ae3cd6dbf.png>
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#80 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ACWcxqIWhp8uK8laZwOLaEUzqZqAxH_yks5rfvRZgaJpZM4Lw6R5>
.
|
I just upgraded to beta 6 and as far as I can tell, the issue is still there |
Can confirm this is still happening in branch af787e5 |
Have same problem :( |
I have the same problem with a Did you had time to work on your fix @grabbou ? |
Can I help somehow? |
@JulianKingman, yes! If you can write a PR for TabsRouter with a few test cases, it would be much appreciated! |
@grabbou @ericvicenti any hints on where to start, what your thoughts are on how to tackle this? |
Hi @JulianKingman, TL;DR Replace what it's here with: if (didNavigate) {
const childState = state.routes[activeTabIndex];
let newChildState;
const tabRouter = tabRouters[action.routeName];
if (action.action) {
newChildState = tabRouter
? tabRouter.getStateForAction(action.action, childState)
: null;
} else if (!tabRouter && action.params) {
newChildState = {
...childState,
params: {
...(childState.params || {}),
...action.params,
},
};
}
if (newChildState && newChildState !== childState) {
const routes = [...state.routes];
routes[activeTabIndex] = newChildState;
return {
...state,
routes,
index: activeTabIndex,
};
}
} (And now the explanation...) In order to know where the issue is located, I did the following
|
The contributors guide on the website will show you how to run tests. You can add a new test for TabsRouter which sets up two routers in a way similar to DrawerNavigator. Then you can write a test that verifies that |
Wow, thanks @mgtitimoli , that looks great. |
The Third Parameter passed gets undefined too, navigate('screen', {}, {type, routName, params}) I have a nested TabNavigator in a StackNavigator, I navigate from a DrawerNavigator to the StackNavigator one DrawerNavigator -> navigate() -> StackNavigator -> TabNavigator |
I wanna send props from HomeScreen to NewNote1 like this : Same issue, DrawerNavigator don't have state.params So, bellow solutions can fixed it.
At button onpress event:
So, at NewNote1 screen, u will receive 2 navigation data, 1 for routeName: 'NewNote', 1 for routeName: 'NewNote1'. DrawerNavigator don't accept params, so data for NewNote will dont have params (name: 'Rob'). But NewNote1 have params (name: 'Job'). As default, if u call params now, u will get error because it will call to NewNote params, not NewNote1. Now, just filter data to get NewNote1 params. Params for NewNote will "undefined".
Hope this can help someone. Sorry for bad english ! |
@quangduz Thank you! You saved my time. |
It is not working. I tried everything. Nothing works. |
@montao, what is not working? What do you mean by advanced app? Can you show an example code snippet of what is not working for you? Please try the latest version of the library because we may have already fixed the problem. If you still see the problem, please file a new issue with all of these details. |
Note: I am new to react stuff (just been hacking it for couple of days) so I might have the cat by the **** but I spent so many hours reading different solutions to this I just had to comment. @quangduz your solution looks like it works but it actually does two calls (NewNoteStack and NewNote1) which mucks up your stack (gives a you a premature back arrow) Scenario 1: initialRouteParams: {name: 'Job'} on NewNoteStack would do for hard coded parameters. Scenario 2: Some suggested Scenario 2 use cases:
initialRoutParams can be accessed with props.navigation.state.params |
It really surpises me that react-navigation doesn't solve the problem of passing params from a stack navigator to a tabs navigator. Is this library not meant for creating complex apps? I can't imagine an application, except the absolute simplest, where this wouldn't be required most of the time. |
Got same issue. |
any updates on this or workaround? |
@i2chris thx for writing this. I tried to get it working yesterday for quite a long time. In sample app without nested navigator it was working for the TabNavigator. But in the big app with nested stack not. Now I know that I do not have to try further. 👎 |
can we pass data which we get from fetching API as drawer items in drawer navigation using react native. Can u guys please help me.... |
You’ll need to use the custom drawer contentComponent, see here: https://reactnavigation.org/docs/en/drawer-navigator.html The easiest way will probably be to pass in a redux-connected component, then pass the fetched data into redux. |
This is a nightmare.. is it really easier to use react navigation. |
@quangduz I have tried your solution, now what I found is, componentDidMount called twice. First time params are undefined and second time got the result. I am not faced this issue for lower version. I upgraded the version to use popToTop function. But now end with this issue. Can you suggest me solution? |
Hii, |
This comment was marked as abuse.
This comment was marked as abuse.
if someone can post a new issue following the issue template i'm happy to look into this |
DrawerNavigator doesn't seem to accept params as the second argument for
props.navigation.navigate
. I'm using custom drawer menu component. Problem is, that it does navigate to the view but the params are not there.Here's how I'm using the
navigation
prop provided to the custom drawer menu component byDrawerNavigator
:Is this by design or a bug?
ps. This is one of my attempts at getting dynamically created navigation items in the drawer menu.
The text was updated successfully, but these errors were encountered: