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

145
Visualizações
React Native: la navegación no está definida

Tengo "ProfileScreen" declarado en App.js

 function App({ navigation }) { return ( <> <StatusBar hidden /> <NavigationContainer> <Stack.Navigator initialRouteName="Home"> <Stack.Screen ... component={HomeScreen} ... /> <Stack.Screen ... component={FeedScreen} ... /> <Stack.Screen ... component={ProfileScreen} ... /> </Stack.Navigator> </NavigationContainer> </> ); }

Accedo a ProfileScreen dentro de FeedScreen.js

 export const ProfileScreen = () => { return( <Text style={{ textAlign: "left", color: "black", fontSize: 24, fontFamily: 'Montserrat_100Thin_Italic' }}> Hello </Text> ); }

Dentro de FeedScreen.js quiero navegar a ProfileScreen:

 const Item = ({ item }, { navigation }) => { return ( <> <TouchableOpacity onPress={() => navigation.navigate("ProfileScreen")}> <Text style={{ textAlign: "left", color: "white", fontSize: 24, fontFamily: 'Montserrat_100Thin_Italic' }}> <Image style={{ alignSelf: "center", borderRadius: 50 }} source={{ uri: item.profile_picture, width: 48, height: 48 }} /> {item.username} </Text> </TouchableOpacity> </> ); };

Desafortunadamente, todo devuelve Undefined no es un objeto (evaluando 'navigation.navigate')

about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

Para una solución fácil, use el useNavigation dentro de su componente Item de la siguiente manera:

 import { useNavigation } from '@react-navigation/native'; const Item = ({item}) => { const navigation = useNavigation(); return ( <TouchableOpacity onPress={() => navigation.navigate('ProfileScreen')}> <Text style={{ textAlign: 'left', color: 'white', fontSize: 24, fontFamily: 'Montserrat_100Thin_Italic', }}> <Image style={{alignSelf: 'center', borderRadius: 50}} source={{uri: item.profile_picture, width: 48, height: 48}} /> {item.username} </Text> </TouchableOpacity> ); };
about 4 years ago · Juan Pablo Isaza Relatório

0

Su sintaxis era incorrecta para usar el accesorio de navigation dentro de FeedScreen Debería ser así

const Item = ({ item , navigation }) => {

about 4 years ago · Juan Pablo Isaza 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