Closed brentvatne closed 5 years ago
An alternative for this would be to wrap FriendScreen so we have BrentFriendScreen which passes in some props. This is maybe also fine and makes me hesitant to want to include something like initialParams unless we have some motivating use cases where this is infeasible. So let's gather use cases here.
I wouldn't say technically infeasible, but I don't think creating 6+ wrapper screen components for the same screen just because you can't pass in initialParams
is a good model.
I used a hack to fake initialParams for this very use case in a released app. Though I got tired of DrawerNavigator's limitations and started a refactor to make a future version just use a single Stack: StackNavigator()
route and handle drawer items and handle dispatching navigation myself with reset.
Every single drawer item visible in this screenshot is the same Inbox
screen but with different params:
@dantman - could you open a RFC for this? I'd love to get this in soon
I will try to create a PR asap!
Could we call this defaultParams
instead? I think its more technically accurate, because the initial params of the route may be overridden by the navigation actions
I also want to realize a Drawer with different items navigating in one same stack.
Using params didn't work for me. Adding params
to the RouteConfigs of my createDrawerNavigator
did nothing. The params of a route were still empty. (react-navigation 2.18.2)
With setting up a CustomDrawerItems
overwriting the onItemPress
method, I am able to render the items and navigate correctly in one main stack.
My problem is, that the active item in my drawer is not changing. It is always the first item, which is active ('Start' in my example). I wonder how to set a clicked item active?
@donni106 - because it's not released yet, it's only in the latest alpha version of 3.0. post a new issue with exactly what you want please
It may be useful to specify default params in some cases, eg: to reuse screens for multiple routes.
An alternative for this would be to wrap
FriendScreen
so we haveBrentFriendScreen
which passes in some props. This is maybe also fine and makes me hesitant to want to include something likeinitialParams
unless we have some motivating use cases where this is infeasible. So let's gather use cases here.