Search code examples
iosfacebookreact-nativemobile-application

react-native NavigatorIOS is not working as expected


I am implementing a practice application in react-native for IOS. I am using NavigatorIOS for navigation. I want to remove first route from navigation stack after successful login so that user won't come back. I am using .replace() function for this purpose and it replaces the route but navigation title remains unchanged.

Here are Images and related code to explain scenario.

  1. Login screen

    <NavigatorIOS style={styles.container} initialRoute={{ title: 'LOGIN', component: LoginScreen }}/>

enter image description here

  1. After successful login app navigates to home screen which should have title 'HOME' as specified in code

    this.props.navigator.replace({ title: 'HOME', component: HomeScreen, passProps: {token: responseData.token} });

enter image description here

  1. Next navigating to news, it still shows login on the back button. I just used push() method to push new view to stack.

    enter image description here

  2. Here is the main issue I am concerned with and cannot understand why this is happening. When is press back button viz '< LOGIN' it navigates to home screen and its title also changes to "HOME".

on returning back to home screen from child view

I do not get this behavior. Does anyone have idea why it is happening and how can I fix this thing. Help will be much appreciated.


Solution

  • This is a known RN bug. You can track it here.

    I suggest you use Navigator instead.