shubhnik / redux-react-navigation-demos

React-Native + Redux + Redux-Persist + React Navigation ( Authentication Flow with Redux demos)
152 stars 55 forks source link

Log out error #3

Open rammuk opened 6 years ago

rammuk commented 6 years ago

Hi,

I am running your example ( nestedNavigators ) and when I press Logout on the logout screen I get the following error

Unhandled JS Exception: Invariant Violation: Cannot get config because the route does not have a routeName.

I am just starting to use the react navigation with redux so I would appreciate the help, I am sure it's something small and stupid so thanks in advance

JonnyBoy333 commented 6 years ago

I'm also looking into this issue. Seems like a similar issue to one presented here: https://github.com/react-navigation/react-navigation/issues/2282.

The issue described there is that the nav config is not available on the child components natively like it is on the main screens. In order to make it available to the child components you have to use withNavigation to pass the navigator to the child components. Admittedly I'm still trying to figure out how to make this work in this setup but if I make any progress I'll post back here.

pr0da commented 6 years ago

Hi!

I've encountered the same issue, and replacing the "Logout" case in the navigationReducer solved me:

case Logout:
  return initialState;
krewllobster commented 6 years ago

I replaced:

actions: [NavigationActions.init({ routeName: "login" })]

with:

actions: [NavigationActions.navigate({ routeName: "login" })]

In the navigation reducer, in the logout handler. Seems to work?