Search code examples
react-nativewix-react-native-navigation

WIX React Native Navigation: Second screen in stack displays over the first one


I have a navigation in my RN app, based on WIX React Native Navigation. I have two tabs in the app. In the first one "Settings" screen is rendered over "Login" screen, once the app is launched. How can it be solved, if I want to show only "Login" and from it onClick navigate to "Settings"?

enter image description here

export const goToAuth = () =>
  Navigation.setRoot({
    root: {
      bottomTabs: {
        children: [
          {
            stack: {
              children: [
                {
                  component: {
                    name: 'Login',
                    options: {
                      bottomTab: {
                        text: 'Tab One',
                      },
                      topBar: {
                        title: {
                          text: 'Tab One',
                        },
                      },
                    },
                  },
                },
                {
                  component: {
                    name: 'Settings',
                    options: {
                      topBar: {
                        title: {
                          text: 'Tab Two',
                        },
                      },
                    },
                  },
                },
              ],
              options: {
                bottomTab: {
                  text: 'Tab 1',
                },
              },
            },
          },
          {
            component: {
              name: 'PinCode',
              options: {
                bottomTab: {
                  text: 'Tab 2',
                },
              },
            },
          },
        ],
      },
    },
  });

Solution

  • Remove settings component from the stack, your children array should have only the login component and programmatically push the settings screen from login screen when required.

    Navigation.push(this.props.componentId, {
      component: {
        name: 'Settings',
        options: {
          topBar: {
            title: {
              text: 'Settings screen'
            }
          }
        }
      }
    });
    

    This will get you the desired behaviour.