Saturday, 18 January 2020

Move to selected pages in React Native

I have a stack navigator that looks like this:

const MainNavigator = createStackNavigator({
  Home: {screen: HomeScreen},
  Profile: {screen: ProfileScreen},
  Page1: {screen: Page1},
  Page2: {screen: Page2},
  Page3: {screen: Page3},
  Page4: {screen: Page4},
  Page5: {screen, Page5},
});

const App = createAppContainer(MainNavigator);

export default App;

From HomeScreen I go to ProfileScreen by clicking a button:

class HomeScreen extends React.Component {
    render() {
      const {navigate} = this.props.navigation;
      return (
        <Fragment>
        <Button
          title="Go to Jane's profile"
          onPress={() => navigate('Profile', {name: 'Jane'})}
        />
        </Fragment>
      );
    }
  }

On ProfileScreen I want to select some custom pages in a list, like for example Page1, Page3 and Page4. Then using a Next Button on ProfileScreen I want to go to Page1. Using a Next Button on Page1 I want to go on next selected page, Page3. Then using a Next Button on Page3 I want to go on next selected page, Page4.

How can I achieve this functionality in React native?



from Move to selected pages in React Native

No comments:

Post a Comment