Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

155
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda