Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

154
Views
React Native Stack Navigation Hopping Multiple Pages

I am building a react native app and I'm quite confused about how the page navigation is occurring. I seem to have a problem where my navigation is skipping a page.

<NavigationContainer>
      
      <Stack.Navigator initialRouteName="Home">
        <Stack.Screen 
          component={HomeScreen}
          name="Home"
        />
        <Stack.Screen 
          component={FirstScreen}
          name="First"
        />
         <Stack.Screen 
          component={AssignWorkoutScreen}
          name="Third"
        />

        <Stack.Screen 
          component={SecondScreen}
          name="Second"
        />
      </Stack.Navigator>
    </NavigationContainer>

My goal is to achieve the following navigation I want to go from home -> First Screen -> 2nd Screen. However, I run into the issue that when I click the first screen it immediately jumps the first screen to the second one.

Code for Home:

class HomeScreen extends React.Component {
    render() { 
        return (
          <View>
            <Button
              title="First"
              onPress={() => this.props.navigation.push("First")}
            />
            
          </View>
        );
    }
}

Code for First Screen:

class FirstScreen extends React.Component {
  render() {
    return (
        <ScreenContainer>
        ...
            <Button
            title='hey'
            onPress={this.props.navigation.navigate("Second")}/>
        ...

      </ScreenContainer>
 
    );
  }
}

Thank you for all your help!
about 4 years ago · Santiago Gelvez
1 answers
Answer question

0

You are calling the function in the onPress handler instead of passing it a reference to call later.

 <Button
   title='hey'
   onPress={this.props.navigation.navigate("Second")}/>

To This

 <Button
    title='hey'
    onPress={() => this.props.navigation.navigate("Second")}/>
about 4 years ago · Santiago Gelvez Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!