{"action":"created","issue":{"url":"https://api.github.com/repos/react-navigation/react-navigation-redux-helpers/issues/48","repository_url":"https://api.github.com/repos/react-navigation/react-navigation-redux-helpers","labels_url":"https://api.github.com/repos/react-navigation/react-navigation-redux-helpers/issues/48/labels{/name}","comments_url":"https://api.github.com/repos/react-navigation/react-navigation-redux-helpers/issues/48/comments","events_url":"https://api.github.com/repos/react-navigation/react-navigation-redux-helpers/issues/48/events","html_url":"https://github.com/react-navigation/react-navigation-redux-helpers/issues/48","id":339341281,"node_id":"MDU6SXNzdWUzMzkzNDEyODE=","number":48,"title":"react native android hardware back button","user":{"login":"aftabhussain02","id":37233949,"node_id":"MDQ6VXNlcjM3MjMzOTQ5","avatar_url":"https://avatars0.githubusercontent.com/u/37233949?v=4","gravatar_id":"","url":"https://api.github.com/users/aftabhussain02","html_url":"https://github.com/aftabhussain02","followers_url":"https://api.github.com/users/aftabhussain02/followers","following_url":"https://api.github.com/users/aftabhussain02/following{/other_user}","gists_url":"https://api.github.com/users/aftabhussain02/gists{/gist_id}","starred_url":"https://api.github.com/users/aftabhussain02/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aftabhussain02/subscriptions","organizations_url":"https://api.github.com/users/aftabhussain02/orgs","repos_url":"https://api.github.com/users/aftabhussain02/repos","events_url":"https://api.github.com/users/aftabhussain02/events{/privacy}","received_events_url":"https://api.github.com/users/aftabhussain02/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-07-09T07:52:34Z","updated_at":"2018-07-09T12:43:15Z","closed_at":"2018-07-09T12:43:15Z","author_association":"NONE","body":"hello everyone i am new in react-native and stuck at android hardware back button integration in https://reactnavigation.org/docs/en/redux-integration.html#handling-the-hardware-back-button-in-android  i am getting error of undefined is not an object (evaluating 'state.routes')\r\nbelow is my code\r\n\r\n`\r\nconst AppStack = createStackNavigator({\r\n  mainScreen: {\r\n    screen: MainScreen,\r\n    navigationOptions: ({ navigation }) => ({\r\n      header: <SearchHeader navigation={navigation} />\r\n    })\r\n  },\r\n  userProfile: {\r\n    screen: UserProfile,\r\n    navigationOptions: ({ navigation }) => ({\r\n      headerTitle: 'Profile',\r\n      headerTitleStyle: {\r\n        flex: 1,\r\n      textAlign: 'center',\r\n      alignSelf: 'center'\r\n     },\r\n      headerRight: (<View style={{ paddingRight: 15 }} >\r\n                      <Icon onPress={() => navigation.navigate('EditUserProfile')} name=\"edit\" />\r\n                    </View>)\r\n    })\r\n  },\r\n  editUserProfile: {\r\n    screen: EditUserProfile,\r\n\r\n    navigationOptions: ({ navigation }) => ({\r\n      headerTitle: 'Edit Profile',\r\n      headerTitleStyle: {\r\n      flex: 1,\r\n      textAlign: 'center',\r\n      alignSelf: 'center'\r\n     },\r\n      headerRight: (<View style={{ paddingRight: 15 }} >\r\n                      <Icon onPress={() => navigation.navigate('logout')} name=\"exit-to-app\" />\r\n                    </View>)\r\n    })\r\n  },\r\n  PrivateChat: {\r\n    screen: PrivateChat,\r\n    }\r\n  },\r\n  logout: {\r\n    screen: Logout\r\n  }\r\n},\r\n{\r\n  initialRouteName: 'mainScreen',\r\n});\r\n\r\nconst AuthStack = createStackNavigator({\r\n  auth: {\r\n  screen: Form,\r\n  navigationOptions: {\r\n    header: null\r\n  }\r\n} });\r\n\r\nconst SwitchNavigator = createSwitchNavigator(\r\n  {\r\n    AuthLoading: AuthLoadingScreen,\r\n    App: AppStack,\r\n    Auth: AuthStack\r\n  },\r\n  {\r\n    initialRouteName: 'AuthLoading',\r\n  }\r\n);\r\n\r\nexport const MainNavigation = createDrawerNavigator({\r\n  Home: {\r\n    screen: SwitchNavigator\r\n  }\r\n},\r\n{\r\n  contentComponent: (props) => (\r\n    <DrawerNavigation {...props} />\r\n)\r\n});\r\n\r\n// Create middleware and connect\r\nexport const appNavigatorMiddleware = createReactNavigationReduxMiddleware(\r\n  'root',\r\n  state => state.nav\r\n);\r\n\r\nconst ReduxAppNavigator = reduxifyNavigator(MainNavigation, 'root');\r\n\r\n// create nav component\r\nclass ReduxNavigation extends PureComponent {\r\n  componentDidMount() {\r\n    BackHandler.addEventListener('hardwareBackPress', this.onBackPress);\r\n  }\r\n\r\n  componentWillUnmount() {\r\n    BackHandler.removeEventListener('hardwareBackPress', this.onBackPress);\r\n  }\r\n\r\n  onBackPress = () => {\r\n    const { dispatch, state } = this.props;\r\n    if (state.index === 0) {\r\n      return false;\r\n    }\r\n\r\n    dispatch(NavigationActions.back());\r\n    return true;\r\n  };\r\n\r\n  render() {\r\n    const { dispatch, state } = this.props;\r\n    console.log(this.props);\r\n    return <ReduxAppNavigator dispatch={dispatch} state={state} />;\r\n  }\r\n}\r\n\r\nconst mapStateToProps = state => {\r\n  console.log(state.nav);\r\n  return { state: state.nav };\r\n};\r\n`\r\n\r\nexport default connect(mapStateToProps)(ReduxNavigation);\r\n\r\nafter some changes navigation is working but back button still closing the app and maybe the reason is that state.index is not changing it value it is 0 on every screen i am opening maybe because of switchnavigation\r\n\r\n> \r\n    \"react-navigation\": \"^2.5.1\",\r\n    \"react-navigation-redux-helpers\": \"^2.0.0-beta.1\"\r\n"},"comment":{"url":"https://api.github.com/repos/react-navigation/react-navigation-redux-helpers/issues/comments/403465712","html_url":"https://github.com/react-navigation/react-navigation-redux-helpers/issues/48#issuecomment-403465712","issue_url":"https://api.github.com/repos/react-navigation/react-navigation-redux-helpers/issues/48","id":403465712,"node_id":"MDEyOklzc3VlQ29tbWVudDQwMzQ2NTcxMg==","user":{"login":"Ashoat","id":863579,"node_id":"MDQ6VXNlcjg2MzU3OQ==","avatar_url":"https://avatars0.githubusercontent.com/u/863579?v=4","gravatar_id":"","url":"https://api.github.com/users/Ashoat","html_url":"https://github.com/Ashoat","followers_url":"https://api.github.com/users/Ashoat/followers","following_url":"https://api.github.com/users/Ashoat/following{/other_user}","gists_url":"https://api.github.com/users/Ashoat/gists{/gist_id}","starred_url":"https://api.github.com/users/Ashoat/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Ashoat/subscriptions","organizations_url":"https://api.github.com/users/Ashoat/orgs","repos_url":"https://api.github.com/users/Ashoat/repos","events_url":"https://api.github.com/users/Ashoat/events{/privacy}","received_events_url":"https://api.github.com/users/Ashoat/received_events","type":"User","site_admin":false},"created_at":"2018-07-09T12:43:15Z","updated_at":"2018-07-09T12:43:15Z","author_association":"MEMBER","body":"See #44"}}
{"actor":{"display_login":"Ashoat"}}